@W-23748899 feat(composition): render if/then/else conditional schemas - #101
Merged
alexpmule merged 2 commits intoAug 26, 2026
Conversation
JSON Schema 2020-12 / OAS 3.1 if/then/else keywords were parsed by AMF but not rendered: a shape whose only content was a conditional fell through to the AnyShape scalar fallback and collapsed to a generic "Any" badge. Detect shacl#if/then/else in _typeChanged (raw IRIs built from the frozen shacl namespace prefix, since amf-helper-mixin exposes no if/then/else members) and render each present branch via a recursive api-type-document, mirroring the existing oneOf/anyOf/allOf pattern. then and else are independently optional per JSON Schema, so an if-plus-else shape without then renders both branches, not a blank.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Render JSON Schema 2020-12 / OAS 3.1
if/then/elseconditional schemas inapi-type-document.AMF 5.11 already parses these keywords into
shacl#if/shacl#then/shacl#elsetriples with the branch shapes fully present, but the component had no rendering support for them. A shape whose only content was a conditional fell through to theAnyShapescalar fallback in_typeChangedand collapsed to a generic "Any" badge — the branch properties (kind/breed/indoor) were silently dropped.Why
Follow-up to #100 (W-23748896), which added OAS 3.1 composition-label support but explicitly scoped out conditional schemas. Filed as W-23748899 under the OAS 3.1/3.2 API Console umbrella (TD-0333486).
How
_typeChanged): a single additive check after the existingif / else-ifchain flagsisConditionalwhen the shape carries theifkeyword and resolves the three branch shapes. It only ever clearsisScalar(gated onisConditional) and never writes any other flag, sooneOf/anyOf/allOf/object detection cannot regress.amf-helper-mixinnamespace exposes noif/then/elsemembers, so the IRIs are built from the existing shacl namespace prefix and passed through_getAmfKeyexactly like every other shacl key in the file. No change toamf-helper-mixin._conditionalTemplate): mirrors the existing_anyTemplate/_oneOfTemplatepattern — each present branch renders via a recursive<api-type-document>, reusing the existing property/enum rendering (theifcondition'sconst: dogsurfaces through the existingshacl#inpath).thenandelseare independently optional per JSON Schema, so anif+elseshape withoutthenrenders both branches instead of a blank.Scope
amf-helper-mixin,TypeStyles.js, or the property-rendering components.oneOf/anyOf/allOf(unchanged), OAS 3.2-specific keywords.Testing
New
describe('Conditional type (if/then/else)')block (runs in both Regular and Compact model variants) against the existingPetKindFieldsfixture fromdemo/oas31-webhooks:isConditionaltrue /isScalarfalse (does not collapse to "Any") — AC1if/then/elseresolve to NodeShape branches — AC1kind/breed/indoor, and theifcondition shows theconstvaluedog— AC2if+else-without-thenrenders If + Else with no silent blank — AC1 edgeFull suite: 586 passed, 0 failed, 13 skipped —
oneOf/anyOf/allOfblocks unchanged (AC3).Acceptance criteria
demo/oas31-webhooksPetKindFieldsrenderskind=dog(If) /breed(Then) /indoor(Else)oneOf/anyOf/allOfrenderingNotes for reviewers
W-23748896-composition-labels(@W-23748896 feat(composition): render meaningful labels for oneOf/anyOf/allOf variants (OAS 3.1) #100) — it depends on theoas31-webhooksfixture that PR adds. Base retargets tomasteronce @W-23748896 feat(composition): render meaningful labels for oneOf/anyOf/allOf variants (OAS 3.1) #100 merges.Screenshots