kstasik / schema-tools

Set of tools for codegen, preprocessing and validation of json-schema and openapi spec
MIT License
41 stars 13 forks source link

dereference to include indirect schemas #107

Open jayvdb opened 10 months ago

jayvdb commented 10 months ago

This may be very similar underlying problem of https://github.com/kstasik/schema-tools/issues/67

If the top level openapi doc links to a schema in another doc, and that schema refers to other schemas, they are inlined when using .with_create_internal_references(true).

    SchemaA:
      $ref: "./schemas/SchemaA.yaml#/components/schemas/SchemaA"

schemaA.yaml

    SchemaB:
      type: string
    SchemaA:
      $ref: "#/components/schemas/SchemaB"

results in

    SchemaA:
      type: string

it would be nice if it was possible to emit

    SchemaB:
      type: string
    SchemaA:
      $ref: "#/components/schemas/SchemaB"

the above example is quite contrived. The reason to keep schemas in other docs intact becomes more obvious when the schemas are more complicated.