Repository navigation
fix(rapidoc): keep fields when allOf wraps a single composed schema - #1172
Conversation
A one-member allOf was treated as a primitive whenever the member had no
properties or items. When that member is itself an allOf/oneOf/anyOf
(e.g. a $ref to a composed schema next to a description), the schema
table showed {missing-type-info} and the example dropped the field.
Fixes rapi-doc#1170
|
Thanks for the clear write-up and the tests. The diagnosis matches #1170, and moving the three checks into one helper is a nice cleanup. There's one change I'd like before merging. value:
description: Amount or label
allOf:
- oneOf:
- type: string
- type: integerBefore, the shortcut merged the member into the outer schema, so the field rendered as a union row with the outer description. With this PR it goes through the merge path: the union ends up in Could you limit the Two smaller notes:
|
Fixes #1170
Base branch:
masterA one-member
allOfwas handled as a "primitive" shortcut whenever the member had nopropertiesoritems. That's also true when the member is itself anallOf/oneOf/anyOf, which is the commonallOf: [$ref]+descriptionpattern pointing at a composed schema. InschemaToASTthe shortcut spreads the outer schema over the member, so the member's ownallOfgets replaced and then deleted, and the field renders as{missing-type-info}. InschemaToSampleObjthe same check returns nothing, so the field is missing from the generated example.handleAllOfSchema(object notation) had the same condition.The three checks now go through one small helper that also requires the member to have no
allOf/oneOf/anyOf, so composed members fall through to the normal merge path, which already handles them.Tests: added two cases to
tests/unit/schema-ast.test.jsusing the schema from the issue. Both fail on master (kindisprimitive, example fields are undefined) and pass with the change.npm run test:unit(474 pass),npm run lintandnpm run formatare clean.test:portalhas the same 13 failures with and without the change here, andtest:componentneeds Chrome, which I don't have locally.