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

feat: add route.RequestContentType #177

Merged
merged 1 commit into from
Aug 29, 2024
Merged

feat: add route.RequestContentType #177

merged 1 commit into from
Aug 29, 2024

Conversation

dylanhitt
Copy link
Collaborator

@dylanhitt dylanhitt commented Aug 29, 2024

closes #159

Provides the ability for the user to explicitly
set what content types and request body can be.
Maintains the defaullt of application/json and application/xml

@dylanhitt dylanhitt force-pushed the RequestContent branch 2 times, most recently from 1169eee to 15ebe2c Compare August 29, 2024 02:03
openapi_operations.go Outdated Show resolved Hide resolved
Provides the ability for the user to explicitly
set what content types and request body can be.
Maintains the defaullt of `application/json` and `application/xml`
Copy link
Member

@EwenQuim EwenQuim left a comment

Choose a reason for hiding this comment

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

Nice, thank you very much!

@dylanhitt dylanhitt merged commit e514438 into main Aug 29, 2024
5 checks passed
@dylanhitt dylanhitt deleted the RequestContent branch August 29, 2024 15:52
@@ -19,6 +19,8 @@ func (rs PetsRessources) Routes(s *fuego.Server) {
fuego.Get(petsGroup, "/{id}", rs.getPets)
fuego.Get(petsGroup, "/by-name/{name...}", rs.getPetByName)
fuego.Put(petsGroup, "/{id}", rs.putPets)
fuego.Put(petsGroup, "/{id}/json", rs.putPets).
RequestContentType("application/json")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe

Suggested change
RequestContentType("application/json")
ExpectContentType("application/json")

or

Suggested change
RequestContentType("application/json")
RequireContentType("application/json")

or

Suggested change
RequestContentType("application/json")
AcceptContentType("application/json")

What do you think?

Copy link
Collaborator Author

@dylanhitt dylanhitt Aug 29, 2024

Choose a reason for hiding this comment

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

Not sure I'm following?

We're applying the Content-Type for the openapi RequestBody. The following follows the semantics that was used for other operations.

Copy link
Contributor

Choose a reason for hiding this comment

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

I assumed the method was expecting the caller to send this.

I might have misunderstood the PR purpose

openapi_operations.go Show resolved Hide resolved
openapi_operations_test.go Show resolved Hide resolved
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.

Spec should not assume xml responses
3 participants