Skip to content
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

fix: request bodies should take required property into account #1277

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

AllieJonsson
Copy link
Contributor

@AllieJonsson AllieJonsson commented Mar 22, 2024

Status

READY

Description

Fixes #1111

Takes the required property of request bodies into account. We till make it required by default, but setting it to required: false will make it optional.

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

  1. yarn generate:swr
  2. check tests/generated/swr/optional-request-body/endpoints.ts. Endpoints without a required property has the request body required. Endpoints with a required: false property has the request body as optional.

melloware
melloware previously approved these changes Mar 22, 2024
Copy link
Member

@soartec-lab soartec-lab left a comment

Choose a reason for hiding this comment

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

@AffeJonsson
Hi, Thank you for great PR, I commented on one consultation, so please check it.

@@ -0,0 +1,223 @@
openapi: '3.0.0'
Copy link
Member

Choose a reason for hiding this comment

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

We will continue to maintain the tests, so we would like to keep them to a minimum as much as possible. Is it possible to slim down to a minimized case that only checks the request body?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely, I'll fix!

@soartec-lab soartec-lab added this to the 6.26.0 milestone Mar 28, 2024
@soartec-lab soartec-lab added the bug Something isn't working label Mar 28, 2024
@soartec-lab soartec-lab self-assigned this Mar 28, 2024
@anymaniax
Copy link
Collaborator

anymaniax commented Mar 28, 2024

I understand that in the specification it’s optional per default but 99% if you have a request body you want it required no?

@AllieJonsson
Copy link
Contributor Author

That's probably true. Maybe it would be better if it's required as default. I'll change that, but at least with this change it'll take the required prop into account

@AllieJonsson AllieJonsson changed the title fix: request bodies should be optional by default fix: request bodies should take required property into account Mar 29, 2024
Copy link
Member

@soartec-lab soartec-lab left a comment

Choose a reason for hiding this comment

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

Thank you.

@soartec-lab soartec-lab merged commit 661a6ad into orval-labs:master Mar 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Orval does not respect the "optional by default" requestBody for OpenAPI 3.0
4 participants