Skip to content

request body in openapi no need to append the components #2069

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

frankzye
Copy link

@frankzye frankzye commented Jul 21, 2025

Fixes # .

reproduce:

  • start up server, and call one of the api with Post and body
  • open swagger and refresh
    error:

Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['requestBody']:
{'oneOf': [{'$ref': '#/definitions/RequestBody'},
{'$ref': '#/definitions/Reference'}]}

Changes proposed in this pull request:

request body in openapi no need to append the components

@chrisinmtown
Copy link
Contributor

Not quite sure so I want to ask, does this PR fix this issue: #2029 ?

@frankzye
Copy link
Author

Not quite sure so I want to ask, does this PR fix this issue: #2029 ?
yes, fix the issule

@chrisinmtown
Copy link
Contributor

Fixes # .

Thanks, very glad to hear it. Please extend your commit message to reference that issue with a "Fixes" comment like shown above.

@frankzye frankzye force-pushed the bugfix/request-body-no-components branch from 806757c to c3f4917 Compare July 21, 2025 13:40
@frankzye frankzye force-pushed the bugfix/request-body-no-components branch from c3f4917 to b74da36 Compare July 21, 2025 13:41
@frankzye
Copy link
Author

Not quite sure so I want to ask, does this PR fix this issue: #2029 ?
yes, fix the issule

updated

@chrisinmtown
Copy link
Contributor

This project has an enormous suite of automated tests. Would you please consider adding a new test that checks the revised behavior? I.e., the test should fail on released version 3.2, succeed with this change.

@frankzye
Copy link
Author

This project has an enormous suite of automated tests. Would you please consider adding a new test that checks the revised behavior? I.e., the test should fail on released version 3.2, succeed with this change.

added with tests

@chrisinmtown
Copy link
Contributor

@Ruwann @RobbeSneyders would one of you maintainers please approve a run of the GitGHub workflow to validate this change?

def test_openapi_schema_validate_with_request_body_change(simple_app):
app_client = simple_app.test_client()

if simple_app._spec_file == "openapi.yaml":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please help me understand the need for this if clause? Are there multiple instances of simple_app and some have a different spec file? I suppose you are trying to increase the chance that the app is listening at endpoint /v1.0/test-default-object-body. Seems like all the other tests in this file have this kind of assumption, so I'm not sure it's necessary to check in this one. Or maybe I'm missing something huge :)

Copy link
Contributor

@chrisinmtown chrisinmtown Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more comment, if you can please have patience with me. I see there is a test file test_responses.py. Because this new test case doesn't actually exercise any parameters, maybe you might consider moving this new case to that file?

def with_definitions(self, schema: dict):
if self.components:
def with_definitions(self, schema: dict, append_components=True):
if self.components and append_components:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that only the init method has pydoc for parameters, the rest of the methods have basically none. With that said, since you are introducing a new parameter with a default value, I think it would be really helpful to add a little pydoc section with a sentence about the new parameter. Please consider it. I'd like to suggest that text, but I am still trying to understand exactly what is being appended here (or not).

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

Successfully merging this pull request may close these issues.

2 participants