-
Notifications
You must be signed in to change notification settings - Fork 9.1k
How are we supposed to generate maintainable openapi files? #1961
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
Comments
Each path item can be a JSON reference object. And JSON references can point to external documents. This means you can split up each path into a separate file, if you really needed to. |
I'm not entirely sure what you mean by this. JSON references can reference structures within an external document. So let's say you had the 2 files:
openapi: 3.0.2
info:
title: My API
version: 1.0.0
paths:
/foo:
$ref: 'path-items.yaml#/foo'
/bar:
$ref: 'path-items.yaml#/bar'
components:
responses:
Bar:
description: A bar
content:
application/json:
schema: { type: object }
foo: # this path item is empty
bar:
get:
operationId: getBar
responses:
'200':
$ref: 'openapi.yaml#/components/responses/Bar' Does this example help at all? |
Yes that's what I meant with
|
For info and servers you could do (not nice but at least):
info:
server:
ServerVariableObjects are not valid by specification in schemas as well if you'd be hypocritical. |
Closing as answered. |
Imagine you had an api with 10 paths with each 8 operations. That would mean 80 operation objects wrapped in 10 path objects.
This alone creates a file that is not really maintainable anymore.
Problem is you can not reference paths externally, amongst many other things.
I wonder how we are supposed to make clean code here that is maintainable?
With swagger-cli I could create
imports
or however you call it.Following this: https://dev.to/mikeralphson/defining-reusable-components-with-the-openapi-specification-4077
I can make them self-contained but I'm currently stuck at paths and how to do it there.
The text was updated successfully, but these errors were encountered: