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

$ref syntax or other? #1

Closed
simlu opened this issue Mar 13, 2018 · 5 comments
Closed

$ref syntax or other? #1

simlu opened this issue Mar 13, 2018 · 5 comments

Comments

@simlu
Copy link

simlu commented Mar 13, 2018

Following this project with interest!

Are you planning to support resolving and loading external yaml files somehow?

@eemeli
Copy link
Owner

eemeli commented Mar 13, 2018

Do you mean an inline reference to a file or URL in one YAML file being loaded during the file's resolution? That's not a feature in existing YAML spec, and as far as I know, it's not on the roadmap for YAML 1.3 or even YAML 2. Could you point me towards a reference for this somewhere? If you're interested in getting something like this included in the spec, you should submit an RFC for it.

Technically something like what you propose could be implemented as a custom data type that would then be included in the schema, but the security implications are significant enough that it would need to be separately loaded and enabled.

@simlu
Copy link
Author

simlu commented Mar 13, 2018

@eemeli Hey! Sorry, I should have clarified. No this is (unfortunately) not part of the yaml specs.

The $ref syntax is described here: json-schema-org/json-schema-spec#514

My preference would be to have something similar added to this repo. Having it disabled / not loaded by default is perfectly fine. However writing it completely separate might also be an option.


We've been looking closely at this repo from various serverless issues and when config loading is restructured this repo would be a potentially dependency. Will get back here at some point.

@eemeli
Copy link
Owner

eemeli commented May 28, 2018

Closing this as a won't-fix issue for now. It's rather unlikely that I'd get to this myself in any sensible timeframe, but I'm not opposed to having it implemented as an extension; I'm pretty sure that the resolve(doc, node): any method used by the schema could be stretched to cover this.

It's also tbh unlikely that something like this would make sense including in the core repo, as loading external files seems like a rather likely point of failure regarding security.

@eemeli eemeli closed this as completed May 28, 2018
@MikeRalphson
Copy link
Contributor

MikeRalphson commented Jan 6, 2019

@simlu if you're still looking, something like oas-resolver might do the trick (although it resolves to a JS object only, not an AST or a CST) or https://github.com/APIDevTools/json-schema-ref-parser - both support JSON and YAML.

@simlu
Copy link
Author

simlu commented Jan 6, 2019

@MikeRalphson We started using yaml-boost (disclaimer, I'm the auther), as it handles various cases nicely for us. Thank you for the reply though. Very interesting and I hadn't seen it before!

eemeli added a commit that referenced this issue Oct 9, 2024
generated from commit 602b3d720f134ee5ca5f03bbc3eda8d1cd083c52
eemeli added a commit that referenced this issue Oct 13, 2024
generated from commit 602b3d720f134ee5ca5f03bbc3eda8d1cd083c52
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

No branches or pull requests

3 participants