openapi-contrib / openapi-schema-to-json-schema

Due to the OpenAPI v3.0 and JSON Schema discrepancy, you can use this JS library to convert OpenAPI Schema objects to proper JSON Schema.
https://www.npmjs.com/package/@openapi-contrib/openapi-schema-to-json-schema
MIT License
242 stars 20 forks source link

feat: Support definitions pattern for when $ref's are't pre-resolved #7

Closed ineentho closed 1 year ago

ineentho commented 4 years ago

Sometimes it isn't ideal to have to resolve refs before running openapi-schema-to-json-schema. In my case I need to run type generators on individual schema files, not the combined schemas I'd get from running something like json-ref-resolver.

This adds a new option called definitionKeywords that takes an array of keywords to treat as "definition objects". Each property in the "definition object" will be treated as a subschema and have all conversions run on them.

I'd expect most people to use definitionKeywords: ['definitions'], but I think leaving that up to the user makes sense since the spec doesn't specify a standard.

philsturgeon commented 4 years ago

Thanks for this! Can you add it to the README so that people know it exists?

ineentho commented 4 years ago

Sure! I think the option is best explained by an example, so I copied the test case example to the readme. Does that work for you?

jonluca commented 1 year ago

Added in https://github.com/openapi-contrib/openapi-schema-to-json-schema/pull/52