Repository navigation
Default parameter name to schema class name or 'body' in schema2parameters - #1077
Closed
DYNOSuprovo wants to merge 1 commit into
Closed
DYNOSuprovo wants to merge 1 commit into
DYNOSuprovo wants to merge 1 commit into
Conversation
…eters Signed-off-by: DYNOSuprovo <DYNOSuprovo@users.noreply.github.com>
Member
|
I wouldn't qualify current behaviour as a bug but oh well. I'm reluctant to add this complexity for a change that seems cosmetic to me. Or is it not? What is your motivation for this? Do you have an example of a real-life use case where this affects users? |
Author
|
Thanks for the feedback @lafrech! The initial thought was addressing #829 where the parameter name was questioned, but you are right that in OpenAPI 2.0 the body parameter name is largely conventional and primarily cosmetic. If you feel this adds unnecessary complexity without enough practical benefit to users, I am completely fine with closing the PR and keeping the existing behavior as-is. |
This file contains hidden or 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
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.
Closes #829
Summary
When
location="body"inOpenAPIConverter.schema2parameters, the parameternamepreviously defaulted unconditionally to"body". This change updatesname: str | None = Noneand dynamically resolves:nameis explicitly provided, use it as specified.nameis not specified andschemais aSchemaclass or instance, default to the schema's class name.schemais not a schema class or instance andnameis not specified, fall back to"body"to preserve a valid OpenAPI 2.0 parameter object.Changes
schema2parametersinsrc/apispec/ext/marshmallow/openapi.pywith dynamic fallback resolution forlocation == "body".test_schema_body_name_defaultintests/test_ext_marshmallow_openapi.pycovering class, instance, custom name, and fallback.CHANGELOG.rst.