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

[REQ] Better support for openapi document inline/nested schemas #15699

Closed
spacether opened this issue May 31, 2023 · 1 comment
Closed

[REQ] Better support for openapi document inline/nested schemas #15699

spacether opened this issue May 31, 2023 · 1 comment
Labels
Enhancement: Feature Inline Schema Handling Schema contains a complex schema in items/additionalProperties/allOf/oneOf/anyOf

Comments

@spacether
Copy link
Contributor

spacether commented May 31, 2023

Is your feature request related to a problem? Please describe.

Please add better support for inline/nested schemas

Describe the solution you'd like

These json schema keywords:

  • additionalProperties
  • allOf
  • anyOf
  • items
  • not
  • oneOf
  • properties

Allow inline schema definitions.
Many generators do not support deep levels of inlining/nesting.
If those schemas are traversed with post order traversal, then accumulated into a list, they can be generated in an order where the root schema that uses the dependencies comes last. Naming should be done in a pre order traversal (reverse the class writing order) to ensure that the root schema has a highest priority name.

This would allow inline schemas to be supported in many more generators.
I wrote a PR that does this in my similar-to python generator project here:
openapi-json-schema-tools/openapi-json-schema-generator#177
Your project could add a similar feature

Example:

schemas:
- SchemaA:
    type: object
    allOf:
    - type: object
       minProperties: 2

Becomes a list of schemas when examining SchemaA

- AllOf1:
    type: object
    minProperties: 2
- SchemaA:
    type: object
    allOf:
    - CodegenProperty AllOf1

Describe alternatives you've considered

  • build nested schema support into other generators
    • many languages would not support this

Additional context

Related issues:

@spacether spacether added Enhancement: Feature Inline Schema Handling Schema contains a complex schema in items/additionalProperties/allOf/oneOf/anyOf labels May 31, 2023
@spacether spacether changed the title [REQ] Better support for openapi document nested schemas [REQ] Better support for openapi document inline/nested schemas May 31, 2023
@spacether
Copy link
Contributor Author

I am no longer a contributor to this repo. Please open a new issue if you plan on adding this feature.

@spacether spacether closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement: Feature Inline Schema Handling Schema contains a complex schema in items/additionalProperties/allOf/oneOf/anyOf
Projects
None yet
Development

No branches or pull requests

1 participant