-
Notifications
You must be signed in to change notification settings - Fork 215
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
tsp-openapi3 - scope top-level parameters to Parameters namespace #4216
Merged
chrisradek
merged 6 commits into
microsoft:main
from
chrisradek:tsp-openapi3-add-context
Aug 29, 2024
Merged
tsp-openapi3 - scope top-level parameters to Parameters namespace #4216
chrisradek
merged 6 commits into
microsoft:main
from
chrisradek:tsp-openapi3-add-context
Aug 29, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chrisradek
requested review from
bterlson,
markcowl,
allenjzhang and
timotheeguerin
as code owners
August 20, 2024 17:02
chrisradek
added
the
openapi3:converter
Issues for @typespec/openapi3 openapi to typespec converter
label
Aug 20, 2024
All changed packages have been documented.
Show changes
|
You can try these changes here
|
markcowl
reviewed
Aug 28, 2024
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.
A few questions and comments.
packages/openapi3/src/cli/actions/convert/transforms/transform-component-schemas.ts
Show resolved
Hide resolved
timotheeguerin
approved these changes
Aug 29, 2024
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 29, 2024
Fixes #4152 Depends on #4216 This PR updates how tsp-openapi3 handles generating models for schemas that use `allOf`. Currently `allOf` is ignored unless there is only 1 member and that member is a schema reference. In this scenario, the model extends the single member. This update now takes all of the schema `allOf` members into consideration when generating a model. - inline-schemas have their properties merged into the model's properties - schema references without a discriminator defined are spread into the model - if only 1 schema reference contains a discriminator, then the model extends it, otherwise these schema references are spread as well. --------- Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
weidongxu-microsoft
pushed a commit
to weidongxu-microsoft/typespec
that referenced
this pull request
Sep 3, 2024
…crosoft#4216) Fixes microsoft#4151 This PR updates tsp-openapi3's model generation so that all top-level parameters (`#/components/parameters`) are nested in a `Parameters` block namespace. Prior to this change, if top-level parameter had the same name as a top-level schema, we would attempt to merge the two. This worked OK if the schema was an object type, but led to broken results if the schema was anything else. Note: In the linked issue, it was suggested that top-level schemas not be scoped to their own namespace, so if a schema is referenced by a parameter, it will now qualify it with the file-level namespace. This PR introduces a `context` object that contains some state that can be passed around. This is useful for keeping track of the file-level namespace and using it when necessary, but the context will also be useful in cases where we need to look at the definition of a referenced schema from another schema. --------- Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
weidongxu-microsoft
pushed a commit
to weidongxu-microsoft/typespec
that referenced
this pull request
Sep 3, 2024
…soft#4232) Fixes microsoft#4152 Depends on microsoft#4216 This PR updates how tsp-openapi3 handles generating models for schemas that use `allOf`. Currently `allOf` is ignored unless there is only 1 member and that member is a schema reference. In this scenario, the model extends the single member. This update now takes all of the schema `allOf` members into consideration when generating a model. - inline-schemas have their properties merged into the model's properties - schema references without a discriminator defined are spread into the model - if only 1 schema reference contains a discriminator, then the model extends it, otherwise these schema references are spread as well. --------- Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
sarangan12
pushed a commit
to sarangan12/typespec
that referenced
this pull request
Sep 16, 2024
…crosoft#4216) Fixes microsoft#4151 This PR updates tsp-openapi3's model generation so that all top-level parameters (`#/components/parameters`) are nested in a `Parameters` block namespace. Prior to this change, if top-level parameter had the same name as a top-level schema, we would attempt to merge the two. This worked OK if the schema was an object type, but led to broken results if the schema was anything else. Note: In the linked issue, it was suggested that top-level schemas not be scoped to their own namespace, so if a schema is referenced by a parameter, it will now qualify it with the file-level namespace. This PR introduces a `context` object that contains some state that can be passed around. This is useful for keeping track of the file-level namespace and using it when necessary, but the context will also be useful in cases where we need to look at the definition of a referenced schema from another schema. --------- Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
sarangan12
pushed a commit
to sarangan12/typespec
that referenced
this pull request
Sep 16, 2024
…soft#4232) Fixes microsoft#4152 Depends on microsoft#4216 This PR updates how tsp-openapi3 handles generating models for schemas that use `allOf`. Currently `allOf` is ignored unless there is only 1 member and that member is a schema reference. In this scenario, the model extends the single member. This update now takes all of the schema `allOf` members into consideration when generating a model. - inline-schemas have their properties merged into the model's properties - schema references without a discriminator defined are spread into the model - if only 1 schema reference contains a discriminator, then the model extends it, otherwise these schema references are spread as well. --------- Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4151
This PR updates tsp-openapi3's model generation so that all top-level parameters (
#/components/parameters
) are nested in aParameters
block namespace.Prior to this change, if top-level parameter had the same name as a top-level schema, we would attempt to merge the two. This worked OK if the schema was an object type, but led to broken results if the schema was anything else.
Note:
In the linked issue, it was suggested that top-level schemas not be scoped to their own namespace, so if a schema is referenced by a parameter, it will now qualify it with the file-level namespace. This PR introduces a
context
object that contains some state that can be passed around. This is useful for keeping track of the file-level namespace and using it when necessary, but the context will also be useful in cases where we need to look at the definition of a referenced schema from another schema.