Closed manstis closed 2 months ago
At the moment, I think we have to support everything from the OpenAPI 3.1 spec, which would include both dependentSchemas
and dependentRequired
, but how much support we provide is may vary.
I think at a minimum we would want to allow:
OASModelReader
or OASFilter
However, we could also add new annotations or add to existing ones.
@manstis Did you have any examples of what you'd want to be able to do in your code to add these properties to the final OpenAPI document?
Hi @Azquelt I forget the exact details other than some notes I captured at the time:
OpenAPI for Backstage Templates
- The generated OpenAPI definition is used to define the parameters for Backstage’s Templates. The parameter (map) entries > are used to generate the input form presented to Users to capture the parameters to execute the workflow (and > dataInputSchema generation, see below).
- Backstage uses react-jsonschema-form that supports a concept > called dependencies to dynamically alter > the form definition. This is not supported in OpenAPI and hence this feature is missing from the SWF PoC. dependencies is only support in OpenAPI 3.1
- SmallRye 3.1 does not support Conditional Schemas.
- See https://github.com/eclipse/microprofile-open-api/issues/567
The issue was that a library is being used to generate forms from JSON schemas. If the JSON schemas defined dependencies (on other schemas) they failed to be recognised and the generated forms incomplete.
I've moved onto other projects now; but can try to answer any questions you have ongoing.
Ok, so checking through what was written above, my understanding is:
dependencies
property (which was in an earlier JSON Schema draft)dependencies
propertyIn #584 , we've made several changes which I think address this:
dependentRequired
property can be set using either annotations or the model API (i.e. with OASModelReader
, static openapi.yaml
file or OASFilter
)
if
/then
/else
, dependentSchemas
)dependencies
property can be set as a custom property using the model API
schema.set("dependencies",
Map.of("credit_card", List.of("billing_address"),
"billing_address", List.of("credit_card"))
);
Based on the above, I think the features being added in 4.0 are sufficient to close this issue, but do feel free to reopen if I've missed anything.
Will there be support to define conditional schemas?
The OpenAPI 3.1 Specification suggests
"For more information about the properties, see JSON Schema Core and JSON Schema Validation."
https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-10.2.2
Both referenced documents cover
dependencies
and/ordependentSchemas
.The older Open API 3.0.x Specification implicitly states conditional schemas are unsupported.
"Additional properties defined by the JSON Schema specification that are not mentioned here are strictly unsupported".
No such comment is made for 3.1 so it could be assumed they are supported.
It is useful for consumers of Open API when used, for example, to generate User input forms programmatically.