swagger icon indicating copy to clipboard operation
swagger copied to clipboard

PetCreate() references params.Pet.ID

Open knweiss opened this issue 7 years ago • 0 comments

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().

knweiss avatar Mar 07 '19 21:03 knweiss