biocad / openapi3

OpenAPI 3.0 data model
BSD 3-Clause "New" or "Revised" License
39 stars 54 forks source link

Support top-level references in components #97

Open isomorpheme opened 4 months ago

isomorpheme commented 4 months ago

From how I understand the OpenAPI 3.0 spec, the following should be allowed and work as expected:

components:
  schemas:
    Foo:
      type: string
    Bar:
      $ref: '#/components/schemas/Foo'

but since type Definitions = InsOrdHashMap Text, which is in turn used in Components (without Referenced), this doesn't parse correctly. This PR changes Definitions so that a Referenced is added in between, and updates other code to deal with the new possibility of a Ref. This is of course a breaking change.

(One use case for writing specs like this is in Haskell code generation: in Chordify's internal tool, a schema that's just a ref to another schema is turned into a newtype of that schema.)