-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Support API mounting #2854
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
I have the same use case, but I would rather show in some way, that under this path there is another API with its own spec and so I would rather reference not the paths included in its OAS, but the full OAS file. So more like a link to another API than a $ref. |
Another possibility could be to allow multiple ...
info: ...
tags: ...
...
paths:
$ref: './service-a.yaml#/paths'
$ref: './service-b.yaml#/paths' Assuming that the content of the referenced file is the following: # service-a.yaml
...
paths:
'/service-a/foo':
... # service-b.yaml
...
paths:
'/service-b/bar':
... The root spec content would finally be rendered as: ...
info: ...
tags: ...
...
paths:
'/service-a/foo':
...
'/service-b/bar':
... Is this simplistic? I know that the current spec doesn't allow it, am I missing some hidden aspect about why it shouldn't be done this way in the first place? |
@SmallhillCZ You make a good point. Especially since mounted APIs can live on different servers (or to specify useful metadata), I think it makes sense to include a complete OAS and not just the paths. A |
@nickshoe As you noted, the spec says the following about this:
Meaning only one |
@MaxenceMaire thanks for clarifying the use of My example was an alternative proposal. Anyways, I like your proposal too (I've put a thumbs up). We ended up defining separate OpenAPI documents for each microservice and using them independently. It would be nice to be able to squash together separate specs, without having to break them down according to the root keys of the spec. If conflicts arise, then one should handle them by changing one of the sub-specs. |
I asked "Reference Objects in Paths Object". |
I believe this is addressed by OAS 4 Moonwalk's separation of concerns principle. Specifically: I'm going to close this as "moved to moonwalk", but please join the linked discussion if you are still interested! |
This follows a comment on issue #647.
It would be great to be able to mount API specs onto another spec for service composition.
As an example, I have two independent services A and B, both having their own OAS files. I would like to 'merge' A and B together into a single, centralized spec.
If both services have, say, a
/resource
endpoint, I would like to discriminate them by prefixing their paths with the name of the services,/A
and/B
respectively (resulting in/A/resource
and/B/resource
).One naive solution would be to list and redefine each path in the root OAS file and
$ref
the related A or B content, but changing the design of either A or B would require updating the root OAS file.A possible alternative would be to support path nesting (discarded here):
I suggest considering introducing a
mount
field under Path Item Objects and taking a Paths Object:The text was updated successfully, but these errors were encountered: