Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for bundling without dereferencing #20

Open
kibertoad opened this issue Jan 8, 2018 · 4 comments
Open

Support for bundling without dereferencing #20

kibertoad opened this issue Jan 8, 2018 · 4 comments

Comments

@kibertoad
Copy link

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.

@jawa-the-hutt
Copy link
Contributor

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:

  1. Paths
  2. Definitions
  3. Parameters
  4. 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.

@m-mohr
Copy link

m-mohr commented Dec 2, 2020

Especially useful for recursive schemas, they completely fail with a "Maximum call stack size exceeded" error

@warmans
Copy link

warmans commented Apr 17, 2021

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.

@flisboac
Copy link

flisboac commented May 19, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants