swagger-combine
swagger-combine copied to clipboard
Support for bundling without dereferencing
JSON Schema $Ref Parser supports bundling schemas as opposed to dereferencing them: https://github.com/BigstickCarpet/json-schema-ref-parser/blob/master/docs/ref-parser.md#bundleschema-options-callback
It would be useful if swagger-combine supported this mode of operation as well.
I've spent some time looking at this in the last 24 hours and think I have the beginning of a solution. Would essentially pass in an option that allows you to keep the references of first level objects. It would then do error checks in combinedSchema to detect duplicates for items such as:
- Paths
- Definitions
- Parameters
- Responses
Any other first level objects that we need to do error checking against?
There would also be the ability to add an options to sort these first level objects alphabetically: Paths
- path a
- path b Definitions
- def a
- def b
I added this second item in after combining several swagger defs together and ending up with a combined definition that was over 100,000 lines. Needed a quick and easy way to visually spot check.
Especially useful for recursive schemas, they completely fail with a "Maximum call stack size exceeded" error
Was this ever implemented? I see some vague references to the resolve config, but I can't see how to use these to prevent de-refefencing.
Dereferencing also seems to fail for multi-level references as well.
For example, you have a data type (in components/schemas) referenced in your response type (in components/responses), that's in turn referenced in your path/method definition (in paths). The data type definition is not exported, yet all of its $ref
across the exported schema remain. This totally breaks the generated schema.
Having an option to bundle some definitions without dereferencing would help to deal with these cases, as well as with circular referencing (which I have come across quite often). It'd also help to decrease the schema's size, for big and/or highly reusable base types.