-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
OpenAPI bundling proposal #2685
Comments
Good point raised on TDC Meeting: naming within |
@darrelmiller If you have any follow up questions after you've read the article again, do let me know! Slack is probably the easiest way to get hold of me =] |
I'm quite sure there isn't a way to bundle non-schema object easily. You'd have to re-write Example ...
paths:
/foo:
$ref: './foo-path-item.openapi.yaml'
get:
parameters: [] ... bundles to ...
paths:
/foo:
$ref: './foo-path-item.openapi.yaml'
components:
'foo.path-item.yaml':
$id: 'foo.path-item.yaml'
get:
parameters: [] We don't have to rewrite the We can also add a place in Example:
paths:
/:
$ref: './foo.openapi.yaml#/components/pathItems/foo'
components:
schemas:
createSchema:
# the $ref below will not resolve here
openapi:
$id: './foo.openapi.yaml'
components:
pathItems:
foo:
post:
requestBody:
required: true
content:
'application/json':
schema:
$ref: '#/components/schemas/createFoo'
schemas:
createFoo:
# The $ref resolves here
type: object This example shows how embedding like this resolves the naming conflict with the "createFoo" schema. |
This is getting so complicated that my recommendation for "how should we bundle OpenAPI documents" would be "just don't". |
It's really not. I expected that people who are not familiar with JSON Schema's
If you're suggesting that OpenAPI documents should always be developed as one document that can be many thousands of lines long, then that's absolutely not an acceptable solution. That wouldn't be an acceptable way to write and maintain code and writing and maintaining OpenAPI documents should be no different. If you're suggesting that tooling needs to know how to follow external references, then that's more reasonable. However, once you support external references, supporting |
Another level of bundling is inlining. We often do this for tools to consume definitions without de-referencing. I'm putting the note here as a reminder, and I apologies if this isn't in scope of bundling. But thought it relevant. |
Folks interested in this issue will likely be interested in the general referencing discussion that has recently started. Bundling is one topic covered. |
This discussion is best continued in the context of Moonwalk (v4.0), specifically at: Closing this in favor of that. |
I was wondering if there is metaplan to formalize bundling of OAS definitions as well. Ben Hutton and Mike Ralphson did a great job of formalizing JSON Schema 2020-12 in their article and set guidelines how to bundle JSON Schemas when present in OAS definitions. That's a great start, but we have other specification objects that can be bundled within OAS spec:
Path Item Object
This will be eliminated in future versions of OAS spec and replaced by Reference Object. We have
components/pathItems
where we can bundle externally referenced Path Item Objects.All spec objects replaceable by Reference Object
We have special fields for all of these objects in Components Object.
Example.externalValue field
Value of externalValue field is resolved and set as value of
value
field of Example ObjectLink.operationRef field
This IMHO is a little bit problematic. If this field is referencing an Operation Object in external document, and there are multiple Link Objects pointing to the same Operation Object defined in this external document, we have no place where to bundle it as there is no reserved field in Components Object. We have reserved extension prefix so we could possibly use
components/x-oas-operations
field.I'm not sure if my reasoning is correct here, but having an explicit guideline how to create Compound OAS definitions/documents would be great.
The text was updated successfully, but these errors were encountered: