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

PetCreate() references params.Pet.ID #24

Open
knweiss opened this issue Mar 7, 2019 · 0 comments
Open

PetCreate() references params.Pet.ID #24

knweiss opened this issue Mar 7, 2019 · 0 comments

Comments

@knweiss
Copy link

knweiss commented Mar 7, 2019

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

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

No branches or pull requests

1 participant