Skip to content

Commit

Permalink
in README use top-level parameter keys for example Pet Store (using S…
Browse files Browse the repository at this point in the history
…corpio::OpenAPI classes)
  • Loading branch information
notEthan committed Apr 23, 2019
1 parent 94a87ab commit a5a56ef
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ let's pick a state and find a pet. we'll go through the rest of the example in t

```ruby
# call the operation findPetsByStatus: http://petstore.swagger.io/#/pet/findPetsByStatus
sold_pets = pet_store_doc.operations['findPetsByStatus'].run(query_params: {status: 'sold'})
sold_pets = pet_store_doc.operations['findPetsByStatus'].run(status: 'sold')
# sold_pets is an array-like collection of JSI instances

# compare to getPetById: http://petstore.swagger.io/#/pet/getPetById
pet1 = sold_pets.detect { |pet| pet.tags.any? }
pet2 = pet_store_doc.operations['getPetById'].run(path_params: {'petId' => pet1['id']})
pet2 = pet_store_doc.operations['getPetById'].run(petId: pet1['id'])
# without ResourceBase, pet1 and pet2 are not considered to be the same though [TODO may change in jsi]

pet1 == pet2
Expand All @@ -180,11 +180,11 @@ pet1.name = ENV['USER']
pet_store_doc.operations['updatePet'].run(body_object: pet1)

# check that it was saved
pet_store_doc.operations['getPetById'].run(path_params: {'petId' => pet1['id']}).name
pet_store_doc.operations['getPetById'].run(petId: pet1['id']).name
# => "ethan" (unless for some reason your name is not Ethan)

# here is how errors are handled:
pet_store_doc.operations['getPetById'].run(path_params: {'petId' => 0})
pet_store_doc.operations['getPetById'].run(petId: 0)
# raises: Scorpio::HTTPErrors::NotFound404Error
# Error calling operation getPetById:
# {"code":1,"type":"error","message":"Pet not found"}
Expand Down

0 comments on commit a5a56ef

Please sign in to comment.