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

Ability to skip dereferencing inline/internal $ref values #214 #250

Closed
wants to merge 3 commits into from

Conversation

marc0l92
Copy link

@marc0l92 marc0l92 commented Dec 9, 2021

Add new option to skip the internal references while parsing the document

This pull request fix the issue: #214

@philsturgeon
Copy link
Member

I'm struggling to see the use case here. So far in #214 it looked like one persons problems were solved with using bundling, then another person was simply using $ref incorrectly (entirely understandable, we've all done it).

Perhaps this is worth merging just for the sake of feature parity with the stoplight tool?

If so, can we document better?

What does skip internal mean? If it means "only replace $ref for external files but keep $ref for internal files" that kinda sounds like bundling? Maybe I've been away from my computer for too long or something. Please help me understand what we're trying to do.

@marc0l92
Copy link
Author

Hello @philsturgeon,
thanks for reviewing this pull request.

You are right to be confused about this issue because it makes the bundling working in a different way, but let me explain you a bit of background.

In my company we created several OpenAPI files using the references in a different way than the official one and we were using a different library bundle them.
The previous library is not supported anymore, so I decided to modify our project to this library to bundle the files because it looks well done and maintained.

The references that this library expect are structured like this:
image

The reference that I'm using in my company are like this:
image

Both approaches have advantages and disadvantages.
For example, the second approach allows you to create links only one layer deep and centralize the versions in a single file (the root). In this way, if a new version of a shared object is released, you need to change it in only one place.
In this example, if you want to migrate to obj3.v4 you need to change it only once.

Another advantage is that you can share parts of an object between apis. In this example, if two apis wants to share the same obj1 but a different implementation of obj3 they can do it without duplicating the file obj1.

This can be useful is some situations but annoying in others. If you look at obj1.v1.json alone you are not able to understand its content until you put it inside a complete api.

Anyway, my goal is not to convince you that this alternative method of linking is a valid one, but explain why the option in this pull request is needed.

My team decided to use the second linking approach long time ago and, if possible, I would like to keep it in this way using this library to do the bundling.

How do you suggest me to document this option in github pages? do you want to rename the option value?

Thanks,
Marco

@philsturgeon
Copy link
Member

Have you seen this? https://apisyouwonthate.com/blog/json-schema-bundling-finally-formalised/

With $id and new tooling that supports $id in $ref, there is no reason for anyone to work on custom solutions or awkward hacks anymore. We could all just use $id.

This codebase has some plans to support the new hotness in #145, which really is a rewrite in the form of https://github.com/APIDevTools/json-schema-reader, but that rewrite has been paused due to life kicking everyone in the face. Experimentation and PRs welcome.

@marc0l92
Copy link
Author

marc0l92 commented Jan 2, 2022

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

Successfully merging this pull request may close these issues.

None yet

2 participants