-
Notifications
You must be signed in to change notification settings - Fork 226
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
Add new cli option for generating Canonicalized Swagger #2677
Conversation
Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status): Website: https://tspwebsitepr.z22.web.core.windows.net/prs/2677/ |
packages/openapi3/src/openapi.ts
Outdated
@@ -374,8 +374,19 @@ function createOAPIEmitter(program: Program, options: ResolvedOpenAPI3EmitterOpt | |||
}); | |||
} | |||
|
|||
function checkOptionCanonicaliedVersion(program: Program): boolean { | |||
if (program.getOption("canonicalized-version") === "true") { |
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.
Those misc options are some legacy behavior and shouldn't be used, please look at this doc on how to specify emitter options https://microsoft.github.io/typespec/extending-typespec/emitters#custom-configuration-options
Can you explain more about the goals of this PR, the scenarios it supports/how the output gets used, etc.? |
Below is a general description about our design of Multi-Versioning in Azure Process (Canonical Version)
This is an initial PR to generate a canonicalized swagger file, which is the superset of all the schemas of all versions. There are constraints like how to deal with @renamedFrom, which are our next step. |
@dinwa-ms I guess the question is more why do we need this in the openapi emitter? This doesn't really make sense as the service will never accept such payload. |
You are correct. Sorry for this mistake. Will revert changes in openapi |
6832fab
to
8bb2a91
Compare
…inwa-ms/typespecfork into dinwa/add-canonicalized-option
Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status): Website: https://tspwebsitepr.z22.web.core.windows.net/prs/2677/ |
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.
Regardless of this being needed in autorest or not, you shouldn't need to change the versioning library and not resort to miscOptions. To run the versioning projection is an opt-in behavior from the emitter there shouldn't be a global option controlling that.
Got that. Will looking into the emitter on this. Thanks |
@dinwa-ms though even for the autorest emitter I don't think we still understand why this is needed, how is this going to be used? It will produce an invalid spec of the service. |
We found issues that there are components in the ARM ecosystem work in a publisher/consumer pattern. The consumer is tied to specific version, but the publisher decides to change it and the updated swagger is incompatible to the consumer. So, we want to have a multi-version schema and the services be able to convert to and from it. Please let me know if this makes sense to you. Also there is the design doc with more details. Thanks |
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.
I don't think we want to produce a cross-version doc as part of the openapi3 emitter, because OpenAPI is inherently versioned. If we have a special need for canonicalized swagger or json, then we should do this in a separate emitter that is microsoft-specific - this will not be of general use to consumers of OpenAPI.
The canonical model is a data model which is a superset of all the other versions.
By adding canonicalized-version option with true value, it will generate a canonicalized swagger file CanonicalizedVersion.openapi.json
tsp compile . --emit=@azure-tools/typespec-autorest --option=canonicalized-version=true
Below is a general description about our design of Multi-Versioning in Azure Process (Canonical Version)
This is an initial PR to generate a canonicalized swagger file, which is the superset of all the schemas of all versions. There are constraints like how to deal with @renamedFrom, which are our next step.