redoc icon indicating copy to clipboard operation
redoc copied to clipboard

fix: hoist and combine allOf subschema titles

Open Drahflow opened this issue 3 years ago • 1 comments

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 https://github.com/Redocly/redoc/issues/932#issuecomment-516315671 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 avatar May 03 '22 14:05 Drahflow

fixes https://github.com/Redocly/redoc/issues/1960

AlexVarchuk avatar May 12 '22 09:05 AlexVarchuk