Skip to content

Should the requestBody be treated like params? #496

@seeker89

Description

@seeker89

Hi,

I was just getting started with oapi-codegen, and thanks a lot for the awesome tool!

One question I have, is that - unless I'm doing something wrong - the request body isn't automatically unmarshalled, so you have to do something like this: https://github.com/deepmap/oapi-codegen/blob/master/examples/petstore-expanded/echo/api/petstore.go#L85-L86

func (p *PetStore) AddPet(ctx echo.Context) error {
	// We expect a NewPet object in the request body.
	var newPet NewPet
	err := ctx.Bind(&newPet)

Whereas, for the other types of parameters, you get a handy struct with things pre-filled:

https://github.com/deepmap/oapi-codegen/blob/master/examples/petstore-expanded/echo/api/petstore.go#L53

func (p *PetStore) FindPets(ctx echo.Context, params FindPetsParams) error {

Is that by design? Not a massive issue, but wouldn't it make more sense to treat the bodies the same way?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions