Swagger 2.0 anyof

Which is equivalent to anyone in Swagger version 2.0, tell me how to update my json file because I want to update my documentation from swagger 1.0 to 2.0.

Thank you for your help.

+6
source share
2 answers

I don't think there is one, and that seems like a big flaw. It is definitely not mentioned in the part of the specification schema object . They call elements that were accepted from the JSON schema, and anyOf not one of them:

The following properties are taken directly from the JSON schema definition and follow the same specifications:

  • $ ref - as a JSON link
  • (see Data Formats for details)
  • title
  • (GFM syntax can be used to represent rich text)
  • default (Unlike JSON Schema, the value MUST match the specific type for the schema object)
  • multipleOf
  • maximum
  • exclusiveMaximum
  • minimum
  • exclusiveMinimum
  • MAXLENGTH
  • MINLENGTH
  • template
  • MaxItems
  • minItems
  • uniqueItems
  • maxProperties
  • minProperties
  • required
  • transfer
  • of type

The following properties were taken from the JSON schema definition, but their definitions were adjusted to reflect the Swagger specification. Their definition is the same as in the JSON schema, only where the original definition refers to the JSON schema definition, the definition of the schema object is used instead.

  • the elements
  • allOf
  • The properties
  • additionalProperties

I think the discriminator field is closest, but that means you need to structure your output to host Swagger.

+4
source

anyOf and oneOf now supported in OpenAPI Specification 3.0 (released July 26, 2017).

+4
source

All Articles