* Bash: Update samples I'm about to make a fix to the bash generator. I'm regenerating the samples in this commit so that the change I make isn't lost amongst the noise. https://github.com/OpenAPITools/openapi-generator/pull/3290 * Bash client: Fix query params seperation Fix bug where empty query parameters weren't separated by ampersands. For example, this ```bash bash bash_keycloak/client.sh -v --oauth2-bearer "$access_token" --host "$api_host" realmUsersGet realm=demo_realm2 email=foo+bar@baz.com ``` would generate the path `/auth/admin/realms/demo_realm2/users?briefRepresentation=email=foo+bar@baz.comfirst=firstName=lastName=max=search=username=`. It now puts ampersands around them to make `/auth/admin/realms/demo_realm2/users?briefRepresentation=&email=foo+bar@baz.com&first=&firstName=&lastName=&max=&search=&username=` Instead of predicting if there is going to be a `parameter_value` ahead of time, we now put in the ampersand if there is a `parameter_value` and existing `query_request_part`. https://github.com/OpenAPITools/openapi-generator/pull/3290 * Bash: Skip query parameters with empty value I have a route with many optional query parameters. I observed that when they weren't specified, they were still included in the routes, but without a value. Running: ```bash bash bash_keycloak/client.sh -v --header "Authorization: Bearer $access_token" --host "$api_host" --dry-run realmUsersGet realm=demo_realm2 email=foo+bar@baz.com username=foo ``` Would produce the route: `http://localhost:8080/auth/admin/realms/demo_realm2/users?briefRepresentation=&email=foo+bar@baz.com&first=&firstName=&lastName=&max=search=&username=foo` After this change it produces the route: ``http://localhost:8080/auth/admin/realms/demo_realm2/users?email=foo+bar@baz.com&username=foo --- I discussed with @wing328 in the pull request about if empty values (eg `username=` should produce an empty query parameter, or if the query parameter should be removed. We decided it should remove the query parameter. https://github.com/OpenAPITools/openapi-generator/pull/3290 ---- The OpenAPI definition I was using: Using: https://github.com/ccouzens/keycloak-openapi/blob/master/keycloak/6.0.json In particular: ```json "/{realm}/users": { "get": { "summary": "Get users Returns a list of users, filtered according to query parameters", "parameters": [ { "in": "query", "name": "briefRepresentation", "schema": { "type": "boolean" }, "style": "form" }, { "in": "query", "name": "email", "schema": { "type": "string" }, "style": "form" }, { "in": "query", "name": "first", "schema": { "type": "integer", "format": "int32" }, "style": "form" }, { "in": "query", "name": "firstName", "schema": { "type": "string" }, "style": "form" }, { "in": "query", "name": "lastName", "schema": { "type": "string" }, "style": "form" }, { "in": "query", "name": "max", "description": "Maximum results size (defaults to 100)", "schema": { "type": "integer", "format": "int32" }, "style": "form" }, { "in": "query", "name": "search", "description": "A String contained in username, first or last name, or email", "schema": { "type": "string" }, "style": "form" }, { "in": "query", "name": "username", "schema": { "type": "string" }, "style": "form" } ], ```
OpenAPI Petstore Bash client
Overview
This is a Bash client script for accessing OpenAPI Petstore service.
The script uses cURL underneath for making all REST calls.
Usage
# Make sure the script has executable rights
$ chmod u+x petstore-cli
# Print the list of operations available on the service
$ ./petstore-cli -h
# Print the service description
$ ./petstore-cli --about
# Print detailed information about specific operation
$ ./petstore-cli <operationId> -h
# Make GET request
./petstore-cli --host http://<hostname>:<port> --accept xml <operationId> <queryParam1>=<value1> <header_key1>:<header_value2>
# Make GET request using arbitrary curl options (must be passed before <operationId>) to an SSL service using username:password
petstore-cli -k -sS --tlsv1.2 --host https://<hostname> -u <user>:<password> --accept xml <operationId> <queryParam1>=<value1> <header_key1>:<header_value2>
# Make POST request
$ echo '<body_content>' | petstore-cli --host <hostname> --content-type json <operationId> -
# Make POST request with simple JSON content, e.g.:
# {
#   "key1": "value1",
#   "key2": "value2",
#   "key3": 23
# }
$ echo '<body_content>' | petstore-cli --host <hostname> --content-type json <operationId> key1==value1 key2=value2 key3:=23 -
# Preview the cURL command without actually executing it
$ petstore-cli --host http://<hostname>:<port> --dry-run <operationid>
Docker image
You can easily create a Docker image containing a preconfigured environment for using the REST Bash client including working autocompletion and short welcome message with basic instructions, using the generated Dockerfile:
docker build -t my-rest-client .
docker run -it my-rest-client
By default you will be logged into a Zsh environment which has much more advanced auto completion, but you can switch to Bash, where basic autocompletion is also available.
Shell completion
Bash
The generated bash-completion script can be either directly loaded to the current Bash session using:
source petstore-cli.bash-completion
Alternatively, the script can be copied to the /etc/bash-completion.d (or on OSX with Homebrew to /usr/local/etc/bash-completion.d):
sudo cp petstore-cli.bash-completion /etc/bash-completion.d/petstore-cli
OS X
On OSX you might need to install bash-completion using Homebrew:
brew install bash-completion
and add the following to the ~/.bashrc:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi
Zsh
In Zsh, the generated _petstore-cli Zsh completion file must be copied to one of the folders under $FPATH variable.
Documentation for API Endpoints
All URIs are relative to /v2
| Class | Method | HTTP request | Description | 
|---|---|---|---|
| AnotherFakeApi | 123Test@$%SpecialTags | PATCH /another-fake/dummy | To test special tags | 
| FakeApi | createXmlItem | POST /fake/create_xml_item | creates an XmlItem | 
| FakeApi | fakeOuterBooleanSerialize | POST /fake/outer/boolean | |
| FakeApi | fakeOuterCompositeSerialize | POST /fake/outer/composite | |
| FakeApi | fakeOuterNumberSerialize | POST /fake/outer/number | |
| FakeApi | fakeOuterStringSerialize | POST /fake/outer/string | |
| FakeApi | testBodyWithFileSchema | PUT /fake/body-with-file-schema | |
| FakeApi | testBodyWithQueryParams | PUT /fake/body-with-query-params | |
| FakeApi | testClientModel | PATCH /fake | To test "client" model | 
| FakeApi | testEndpointParameters | POST /fake | Fake endpoint for testing various parameters | 
| 假端點 | |||
| 偽のエンドポイント | |||
| 가짜 엔드 포인트 | |||
| FakeApi | testEnumParameters | GET /fake | To test enum parameters | 
| FakeApi | testGroupParameters | DELETE /fake | Fake endpoint to test group parameters (optional) | 
| FakeApi | testInlineAdditionalProperties | POST /fake/inline-additionalProperties | test inline additionalProperties | 
| FakeApi | testJsonFormData | GET /fake/jsonFormData | test json serialization of form data | 
| FakeClassnameTags123Api | testClassname | PATCH /fake_classname_test | To test class name in snake case | 
| PetApi | addPet | POST /pet | Add a new pet to the store | 
| PetApi | deletePet | DELETE /pet/{petId} | Deletes a pet | 
| PetApi | findPetsByStatus | GET /pet/findByStatus | Finds Pets by status | 
| PetApi | findPetsByTags | GET /pet/findByTags | Finds Pets by tags | 
| PetApi | getPetById | GET /pet/{petId} | Find pet by ID | 
| PetApi | updatePet | PUT /pet | Update an existing pet | 
| PetApi | updatePetWithForm | POST /pet/{petId} | Updates a pet in the store with form data | 
| PetApi | uploadFile | POST /pet/{petId}/uploadImage | uploads an image | 
| PetApi | uploadFileWithRequiredFile | POST /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | 
| StoreApi | deleteOrder | DELETE /store/order/{order_id} | Delete purchase order by ID | 
| StoreApi | getInventory | GET /store/inventory | Returns pet inventories by status | 
| StoreApi | getOrderById | GET /store/order/{order_id} | Find purchase order by ID | 
| StoreApi | placeOrder | POST /store/order | Place an order for a pet | 
| UserApi | createUser | POST /user | Create user | 
| UserApi | createUsersWithArrayInput | POST /user/createWithArray | Creates list of users with given input array | 
| UserApi | createUsersWithListInput | POST /user/createWithList | Creates list of users with given input array | 
| UserApi | deleteUser | DELETE /user/{username} | Delete user | 
| UserApi | getUserByName | GET /user/{username} | Get user by user name | 
| UserApi | loginUser | GET /user/login | Logs user into the system | 
| UserApi | logoutUser | GET /user/logout | Logs out current logged in user session | 
| UserApi | updateUser | PUT /user/{username} | Updated user | 
Documentation For Models
- $special[modelName]
 - 200Response
 - AdditionalPropertiesAnyType
 - AdditionalPropertiesArray
 - AdditionalPropertiesBoolean
 - AdditionalPropertiesClass
 - AdditionalPropertiesInteger
 - AdditionalPropertiesNumber
 - AdditionalPropertiesObject
 - AdditionalPropertiesString
 - Animal
 - ApiResponse
 - ArrayOfArrayOfNumberOnly
 - ArrayOfNumberOnly
 - ArrayTest
 - Capitalization
 - Cat
 - CatAllOf
 - Category
 - ClassModel
 - Client
 - Dog
 - DogAllOf
 - EnumArrays
 - EnumClass
 - EnumTest
 - FileSchemaTestClass
 - FormatTest
 - HasOnlyReadOnly
 - MapTest
 - MixedPropertiesAndAdditionalPropertiesClass
 - Name
 - NumberOnly
 - Order
 - OuterComposite
 - OuterEnum
 - Pet
 - ReadOnlyFirst
 - Return
 - Tag
 - TypeHolderDefault
 - TypeHolderExample
 - User
 - XmlItem
 
Documentation For Authorization
api_key
- Type: API key
 - API key parameter name: api_key
 - Location: HTTP header
 
api_key_query
- Type: API key
 - API key parameter name: api_key_query
 - Location: URL query string
 
http_basic_test
- Type: HTTP basic authentication
 
petstore_auth
- Type: OAuth
 - Flow: implicit
 - Authorization URL: http://petstore.swagger.io/api/oauth/dialog
 - Scopes:
- write:pets: modify pets in your account
 - read:pets: read your pets