wing icon indicating copy to clipboard operation
wing copied to clipboard

feat: jsify struct schema with docs

Open eladcon opened this issue 6 months ago • 4 comments

Emits struct docs and struct's fields docs into the generated JSON schema.

For example, this struct will emit the following schema:

/// AA is a struct
struct AA {
  /// XXX is a string
  xxx: str;
  yyy: num;
}
const AA = $stdlib.std.Struct._createJsonSchema({
      $id: "/AA",
      type: "object",
      description: "AA is a struct",
      properties: {
        "xxx": { 
           "type": "string" , 
           "description": "```wing\nxxx: str\n```\n---\n XXX is a string" ,
        },
        "yyy": { 
           "type": "number" , 
           "description": "```wing\nyyy: num\n```" ,
        },
      },
      required: [
        "xxx",
        "yyy",
      ]
    });

Checklist

  • [ ] Title matches Winglang's style guide
  • [ ] Description explains motivation and solution
  • [ ] Tests added (always)
  • [ ] Docs updated (only required for features)
  • [ ] Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

eladcon avatar Jul 28 '24 19:07 eladcon