Skip to content

PetCreate() references params.Pet.ID #24

@knweiss

Description

@knweiss

PetCreate() references params.Pet.ID which does not exist at this endpoint i.e. it is always zero.
That means if you POST multiple pets they all will be stored at index 0 overwriting the last pet. Thus PetList() will only ever show a single pet at most. Suggested fix:

--- a/example/internal/pet/pet.go
+++ b/example/internal/pet/pet.go
@@ -34,7 +34,7 @@ func (p *Pet) PetCreate(ctx context.Context, params pet.PetCreateParams) middlew
        p.count++
 
        // store the created pet
-       p.data[params.Pet.ID] = &model
+       p.data[model.ID] = &model
 
        // copy the stored model before response
        retModel := model

Also, because of PetID's omitempty tag the id 0 of the first pet will not be shown in the output of PetList().

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