Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved "required" list for Components generated from unions to child Components. #156

Open
ChristianHansen opened this issue Oct 21, 2020 · 0 comments
Labels
enhancement New feature or request JiraIssueCreated

Comments

@ChristianHansen
Copy link

Describe your request
Instead of adding properties that are required in a reslang structure to the required list for the parent Component, the required list should be on the child Components in case multiple structures in the union have the same properties, but the properties have different required-ness.

For example consider:

union MyUnion {
  s1: Struct1
  s2: Struct2
}

If Struct1 and Struct2 both have sharedProp, but sharedProp is optional in Struct2, then the required list for MyUnion shouldn't include sharedProp, but the required list for Struct1 should:

MyUnionS1
      allOf:
        - $ref: '#/components/schemas/MyUnion'
        - type: object
          properties: ...
          required:
            - sharedProp


MyUnionS2
      allOf:
        - $ref: '#/components/schemas/MyUnion'
        - type: object
          properties: ...

By contrast, with the current code, MyUnion would look something like this

  MyUnion:
      type: object
      properties:
        type:
          type: string
      discriminator:
        propertyName: type
        mapping:
          s1: '#/components/schemas/MyUnionS1'
          s2: '#/components/schemas/MyUnionS2'
      required:
        - type
        - sharedProp

and there would be no required list for MyUnionS1 nor MyUnionS2.

Describe the value this feature would provide
This would disambiguate which values are required for which Components and make the generated OpenAPI spec closer to the likely intent of the auther of the reslang.

@ChristianHansen ChristianHansen added the enhancement New feature or request label Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request JiraIssueCreated
Projects
None yet
Development

No branches or pull requests

2 participants