mattpolzin / OpenAPIKit

Codable Swift OpenAPI implementation.
MIT License
276 stars 35 forks source link

OpenAPIKit inferred required properties #344

Closed mattpolzin closed 8 months ago

mattpolzin commented 8 months ago

Because OpenAPIKit decodes a required entry on a JSON Schema object with no matching properties entry as a .fragment schema, there is no way to differentiate the following two encoded representations:

Foo:
  type: object
  properties:
    a:
      type: string
  required:
    - b

and

Foo:
  type: object
  properties:
    a:
      type: string
    b: {}
  required:
    - b

Note that in the second snippet, b has both an entry in required and an entry in properties.

To fix this, OpenAPIKit should mark fragments that it has inferred to exist (required entry with no properties entry) so that downstream tooling knows the difference. Future versions of OpenAPIKit may do this in a breaking way, but for now version 3.x should do it in a way compatible with 3.0.