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

fix: hoist and combine allOf subschema titles #1977

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Drahflow
Copy link

@Drahflow Drahflow commented May 3, 2022

What/Why/How?

Issues #932 and #1256 raise the point that the typically achieved rendering of the schemas resulting from nestend oneOf and allOf are unexpectedly ugly, namely object.

In #932 (comment) the point is raised that simply using one of the titles of multiple allOf options (e.g. the first one) might be wrong as the other elements might also have added semantics.

Hence this PR collects all schema titles from the subschemas below allOf (pulled down via hoistOneOf or not) and combines them via + for display. Schemas without title are not included, giving the API developer some flexibility to consider them for inclusion in display.

Reference

Closes #932 (differently)
Closes #1256

Testing

Screenshots (optional)

Source:

allOf:
  - type: object
    title: Existing
    properties:
      id:
        type: string
        format: uuid
  - description: Payment instrument (eg. card) data to use.
    title: Payment instrument
    type: object
    oneOf:
      - title: Credit card
        type: object
        properties:
          type:
            type: string
            const: cardInstrument
... [and three more types] ...

combined-titles

Check yourself

  • Code is linted
  • Tested
  • All new/updated code is covered with tests

@Drahflow Drahflow requested a review from a team as a code owner May 3, 2022 14:31
@Drahflow Drahflow requested review from zalesky and anastasiia-developer and removed request for a team May 3, 2022 14:31
@AlexVarchuk AlexVarchuk requested a review from RomanHotsiy May 4, 2022 15:40
Copy link
Collaborator

@AlexVarchuk AlexVarchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Drahflow Thank you a lot for your contribution.
I think it is better to enable it like redoc option.

Please add a boolean option like includeParentToSubschemaTitle or something like that to enable this feature.

Also, add a description of this option to the readme file and add tests for this feature.

Thank

@AlexVarchuk
Copy link
Collaborator

fixes #1960

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants