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

Add anyOf, allOf and oneOf handling to the OpenAPI code templates. #129

Open
davidjwbbc opened this issue Jan 22, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@davidjwbbc
Copy link
Contributor

Description

At present the templates mostly ignore anyOf, allOf and oneOf data types. The only exception being where these have been used on a single sub-type to modify validation parameters for the type, e.g. adding a number range to a numeric type defined elsewhere and referenced with $ref.

Design

If the data type is an anyOf, allOf or oneOf that only has one data type defined then the type is just treated as through it was that simple type.

If the data type has more than one sub-type contained in an allOf, then a structure is created to hold each sub-type under a name derived from the data type. It is a validation error if any of these sub-types fails to parse.

If the data type has more than one sub-type contained in an anyOf, then a structures is created which has a boolean flag for each sub-type and a field for the sub-type with names derived from the sub-type data type. When parsing the boolean flag is set to true is the data type can be parsed as a particular sub-type and the sub-type value set. It is a validation error if none of the boolean flags were set to true.

If the data type has more than one sub-type contained in an oneOf, then an enumeration type indicating the type of field parsed (with an "unparsed" option included) and a union of the sub-types is included. An attempt is made to parse and validate each sub-type:

  • if parsing or validation fails then the next sub-type is attempted
  • if parsing and validation succeeds and the enumeration is "unparsed" then the enumeration is set to the representation for the sub-type and the sub-type value is set. Parsing and validation continues with the next sub-type.
  • if parsing and validation succeeds and the enumeration is not "unparsed" then this is a validation error.
@davidjwbbc davidjwbbc added the enhancement New feature or request label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

1 participant