Chris Couzens 6358b11516 Bash skip empty query param fix (#3290)
* 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"
            }
          ],
```
2019-07-27 21:48:36 +08:00

7.9 KiB

PetApi

All URIs are relative to /v2

Method HTTP request Description
addPet POST /pet Add a new pet to the store
deletePet DELETE /pet/{petId} Deletes a pet
findPetsByStatus GET /pet/findByStatus Finds Pets by status
findPetsByTags GET /pet/findByTags Finds Pets by tags
getPetById GET /pet/{petId} Find pet by ID
updatePet PUT /pet Update an existing pet
updatePetWithForm POST /pet/{petId} Updates a pet in the store with form data
uploadFile POST /pet/{petId}/uploadImage uploads an image
uploadFileWithRequiredFile POST /fake/{petId}/uploadImageWithRequiredFile uploads an image (required)

addPet

Add a new pet to the store

Example

petstore-cli addPet

Parameters

Name Type Description Notes
body Pet Pet object that needs to be added to the store

Return type

(empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: application/json, application/xml
  • Accept: Not Applicable

[Back to top] [Back to API list] [Back to Model list] [Back to README]

deletePet

Deletes a pet

Example

petstore-cli deletePet petId=value api_key:value

Parameters

Name Type Description Notes
petId integer Pet id to delete [default to null]
apiKey string [optional] [default to null]

Return type

(empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: Not Applicable
  • Accept: Not Applicable

[Back to top] [Back to API list] [Back to Model list] [Back to README]

findPetsByStatus

Finds Pets by status

Multiple status values can be provided with comma separated strings

Example

petstore-cli findPetsByStatus  Specify as:  status="value1,value2,..."

Parameters

Name Type Description Notes
status array[string] Status values that need to be considered for filter [default to null]

Return type

array[Pet]

Authorization

petstore_auth

HTTP request headers

  • Content-Type: Not Applicable
  • Accept: application/xml, application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

findPetsByTags

Finds Pets by tags

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

Example

petstore-cli findPetsByTags  Specify as:  tags="value1,value2,..."

Parameters

Name Type Description Notes
tags array[string] Tags to filter by [default to null]

Return type

array[Pet]

Authorization

petstore_auth

HTTP request headers

  • Content-Type: Not Applicable
  • Accept: application/xml, application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getPetById

Find pet by ID

Returns a single pet

Example

petstore-cli getPetById petId=value

Parameters

Name Type Description Notes
petId integer ID of pet to return [default to null]

Return type

Pet

Authorization

api_key

HTTP request headers

  • Content-Type: Not Applicable
  • Accept: application/xml, application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

updatePet

Update an existing pet

Example

petstore-cli updatePet

Parameters

Name Type Description Notes
body Pet Pet object that needs to be added to the store

Return type

(empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: application/json, application/xml
  • Accept: Not Applicable

[Back to top] [Back to API list] [Back to Model list] [Back to README]

updatePetWithForm

Updates a pet in the store with form data

Example

petstore-cli updatePetWithForm petId=value

Parameters

Name Type Description Notes
petId integer ID of pet that needs to be updated [default to null]
name string Updated name of the pet [optional] [default to null]
status string Updated status of the pet [optional] [default to null]

Return type

(empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: Not Applicable

[Back to top] [Back to API list] [Back to Model list] [Back to README]

uploadFile

uploads an image

Example

petstore-cli uploadFile petId=value

Parameters

Name Type Description Notes
petId integer ID of pet to update [default to null]
additionalMetadata string Additional data to pass to server [optional] [default to null]
file binary file to upload [optional] [default to null]

Return type

ApiResponse

Authorization

petstore_auth

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

uploadFileWithRequiredFile

uploads an image (required)

Example

petstore-cli uploadFileWithRequiredFile petId=value

Parameters

Name Type Description Notes
petId integer ID of pet to update [default to null]
requiredFile binary file to upload [default to null]
additionalMetadata string Additional data to pass to server [optional] [default to null]

Return type

ApiResponse

Authorization

petstore_auth

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]