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

Feature request: Composed static OpenAPI documents #382

Open
pe-st opened this issue Oct 27, 2019 · 5 comments
Open

Feature request: Composed static OpenAPI documents #382

pe-st opened this issue Oct 27, 2019 · 5 comments

Comments

@pe-st
Copy link

pe-st commented Oct 27, 2019

While experimenting to prepare a talk (at Eclipsecon Europe 2019) I also tried a static file approach (design-first) with an OpenAPI document split in several parts (as explained in https://dev.to/mikeralphson/defining-reusable-components-with-the-openapi-specification-4077); code generation (with swagger-codegen or openapi-generator) works fine.

I would have liked to get the assembled document from the MicroProfile endpoint /openapi, but both Quarkus and OpenLiberty just return the part that still resides in the main openapi.yaml file (I didn't test with any other implementation).

The MP spec (section 4.2.1) doesn't really say something about multiple files yielding one final document, it just tells to not use multiple 'openapi.xxx' files with different extensions.

There are example projects with Quarkus (design-first-openapi-generator) and OpenLiberty (design-first-swagger-openliberty) in the feature/split branch of this GitHub repo: https://github.com/pe-st/apidocs/tree/feature/split, where I split the OpenAPI document in openapi.yaml and elements.yaml

It would be nice if a future version of the specification could address this feature.

@arthurdm
Copy link
Member

thanks @pe-st

To help build some context on this area, can you please outline the value-add and use cases of having multiple static OAS3 snippets?

@pe-st
Copy link
Author

pe-st commented Oct 30, 2019

@arthurdm I see two use cases

  • maintainability during evolution of the OAS interface (for services with bigger interfaces one big openapi.yaml file can quickly become unwieldy, similar to programming where you like to split code into multiple classes and packages)
  • reusability: let's say you have some basic models/schemas that you're using in multiple services. You could make some core-models.yaml snippet and use it in different services. Maybe you could even pull it in via dependency management (as an OAS snippet stored in a JAR that you pull in with Maven).

I'm not sure what workflows other people use, maybe they develop their OAS document outside the service? I currently evolve my services' interface directly in the services' workspaces and repos, and would welcome a more modular approach for OAS documents.

@EricWittmann
Copy link
Contributor

Overall I agree with this approach to designing the API - it's often vital to be able to e.g. re-use types across multiple API designs. I'm not sure whether it makes sense to support that in MP OpenAPI or whether the assumption is that the content should be normalized first. I tend to think you're right - the spec could support multiple files for a modular design and it would be quite nice. Right now that's a bit at odds with how the spec is written. Need to discuss it to see what is possible. Good topic for the next hangout.

@arthurdm
Copy link
Member

We agreed on the hangout yesterday that this is a good idea - thanks for the sample @pe-st, it helped to illustrate the scenario.

One concern we all share though is related to collisions. The spec will likely need to state that is up to the user to ensure the snippets to not have colliding elements, as the behaviour will be unspecified.

@arthurdm arthurdm added this to the MP OpenAPI 2.0 milestone Apr 14, 2020
@MikeEdgar MikeEdgar removed this from the MP OpenAPI 2.1 milestone Feb 21, 2022
@bmarwell
Copy link

bmarwell commented May 6, 2024

One concern we all share though is related to collisions. The spec will likely need to state that is up to the user to ensure the snippets to not have colliding elements, as the behaviour will be unspecified.

You can already have collisions in other scenarios, no? I would just print out a warning and use the first or last one (just use assumptions until the spec defines it). The warning could include a notice that the behaviour could change in the future and is not stable.

If there is no collision, which is probably 99% of the cases, we can just proceed ahead.

My openapi.yaml file is already very long. I would be happy to see this soon!

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

6 participants