-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Example] make sure all versions use the same shared components$ref
#198
Conversation
$ref
$ref
@@ -9,6 +9,9 @@ servers: | |||
tags: | |||
- name: Thing | |||
description: Short description of what Thing represents | |||
x-v3-schemas: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one time import of your shared schemas
@@ -9,6 +9,9 @@ servers: | |||
tags: | |||
- name: Thing | |||
description: Short description of what Thing represents | |||
x-v3-schemas: | |||
$ref: https://raw.githubusercontent.com/snyk/sweater-comb/v1.5.0/components/parameters/version.yaml | |||
# ^ tag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specify the tag in one place, for every subsequent $ref
@@ -18,7 +21,7 @@ paths: | |||
tags: | |||
- Thing | |||
parameters: | |||
- { $ref: "../../../../../components/parameters/version.yaml#/Version" } | |||
- { $ref: '#/x-v3-schemas/Version' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usage is a lot cleaner
This reorganizes common components into a single components file so that it may be referenced once in an OpenAPI spec using JSON References. End-to-end tests are updated to use the updated references. The component name rule is adjusted to allow this change. It might be tightened up in a followup to check the names of component leaf-nodes. Credit for this awesome idea to @acunniffe, originally proposed in snyk#198 as a proof-of-concept.
This reorganizes common components into a single components file so that it may be referenced once in an OpenAPI spec using JSON References. End-to-end tests are updated to use the updated references. The component name rule is adjusted to allow this change. It might be tightened up in a followup to check the names of component leaf-nodes. Credit for this awesome idea to @acunniffe, originally proposed in snyk#198 as a proof-of-concept.
This reorganizes common components into a single components file so that it may be referenced once in an OpenAPI spec using JSON References. End-to-end tests are updated to use the updated references. The component name rule is adjusted to allow this change. It might be tightened up in a followup to check the names of component leaf-nodes. Credit for this awesome idea to @acunniffe, originally proposed in snyk#198 as a proof-of-concept.
Closing as this is superseded by #199. Thanks again for the example! |
[Example Only] -- do not merge
You all have shared that you plan to put shared schema on GitHub and let users consume them using
$ref
This has some challenges I think using JSON Schema Refs differently could solve.
This is a really simple example where we import your shared schemas to an extension ie
x-v3-schemas
and then, everywhere else, resolve those via#/x-v3-schemas/Target
Right now your shared schemas are still spread across multiple files. To make this work best, I'd suggest having one "entry point" that follows the standard components section OpenAPI conventions:
https://swagger.io/docs/specification/components/
This probably just means adding a registry-like schema that
$ref
out to all the subcomponents you want in the shared schemas users import.