-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
wrong default value for 'name' in schema2parameters #829
Comments
Nope. This is the default name for OAS2 body parameter. User may specify a name or we fallback on "body" as a dummy name (needed because "name" is required in the spec). I just tried to remove this line and it fails |
I understand that I'd say it may make more sense to have something like the following: def schema2parameters(
self,
schema,
*,
location: str,
name: str | None = None,
required: bool = False,
description: str | None = None,
):
location = __location_map__.get(location, location)
# OAS 2 body parameter
if location == "body":
name = (
name or schema.__class__.__name__
if isinstance(schema, marshmallow.Schema)
else str(name)
)
param = {
"in": location,
"required": required,
"name": name,
"schema": self.resolve_nested_schema(schema),
} The test suite still works for this case. Let me know your thoughts on it. |
Sounds reasonable. I don't think it matters much but why not. Should we consider the case where schema is not a Schema and name is not specified, and in this case use "body" as default name, to avoid using str(None)? |
The signature of the method
schema2parameters
inopenapi.py
is the following:I would say body is the default value for
location
and notname
.The text was updated successfully, but these errors were encountered: