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

13 KiB

FakeApi

All URIs are relative to /v2

Method HTTP request Description
createXmlItem POST /fake/create_xml_item creates an XmlItem
fakeOuterBooleanSerialize POST /fake/outer/boolean
fakeOuterCompositeSerialize POST /fake/outer/composite
fakeOuterNumberSerialize POST /fake/outer/number
fakeOuterStringSerialize POST /fake/outer/string
testBodyWithFileSchema PUT /fake/body-with-file-schema
testBodyWithQueryParams PUT /fake/body-with-query-params
testClientModel PATCH /fake To test "client" model
testEndpointParameters POST /fake Fake endpoint for testing various parameters
假端點
偽のエンドポイント
가짜 엔드 포인트
testEnumParameters GET /fake To test enum parameters
testGroupParameters DELETE /fake Fake endpoint to test group parameters (optional)
testInlineAdditionalProperties POST /fake/inline-additionalProperties test inline additionalProperties
testJsonFormData GET /fake/jsonFormData test json serialization of form data

createXmlItem

creates an XmlItem

this route creates an XmlItem

Example

petstore-cli createXmlItem

Parameters

Name Type Description Notes
xmlItem XmlItem XmlItem Body

Return type

(empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16
  • Accept: Not Applicable

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

fakeOuterBooleanSerialize

Test serialization of outer boolean types

Example

petstore-cli fakeOuterBooleanSerialize

Parameters

Name Type Description Notes
body boolean Input boolean as post body [optional]

Return type

boolean

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not Applicable
  • Accept: /

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

fakeOuterCompositeSerialize

Test serialization of object with outer number type

Example

petstore-cli fakeOuterCompositeSerialize

Parameters

Name Type Description Notes
body OuterComposite Input composite as post body [optional]

Return type

OuterComposite

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not Applicable
  • Accept: /

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

fakeOuterNumberSerialize

Test serialization of outer number types

Example

petstore-cli fakeOuterNumberSerialize

Parameters

Name Type Description Notes
body integer Input number as post body [optional]

Return type

integer

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not Applicable
  • Accept: /

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

fakeOuterStringSerialize

Test serialization of outer string types

Example

petstore-cli fakeOuterStringSerialize

Parameters

Name Type Description Notes
body string Input string as post body [optional]

Return type

string

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not Applicable
  • Accept: /

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

testBodyWithFileSchema

For this test, the body for this request much reference a schema named 'File'.

Example

petstore-cli testBodyWithFileSchema

Parameters

Name Type Description Notes
body FileSchemaTestClass

Return type

(empty response body)

Authorization

No authorization required

HTTP request headers

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

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

testBodyWithQueryParams

Example

petstore-cli testBodyWithQueryParams  query=value

Parameters

Name Type Description Notes
query string [default to null]
body User

Return type

(empty response body)

Authorization

No authorization required

HTTP request headers

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

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

testClientModel

To test "client" model

To test "client" model

Example

petstore-cli testClientModel

Parameters

Name Type Description Notes
body Client client model

Return type

Client

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

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

testEndpointParameters

Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

Example

petstore-cli testEndpointParameters

Parameters

Name Type Description Notes
number integer None [default to null]
double float None [default to null]
patternWithoutDelimiter string None [default to null]
byte string None [default to null]
integer integer None [optional] [default to null]
int32 integer None [optional] [default to null]
int64 integer None [optional] [default to null]
float float None [optional] [default to null]
string string None [optional] [default to null]
binary binary None [optional] [default to null]
date string None [optional] [default to null]
dateTime string None [optional] [default to null]
password string None [optional] [default to null]
callback string None [optional] [default to null]

Return type

(empty response body)

Authorization

http_basic_test

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]

testEnumParameters

To test enum parameters

To test enum parameters

Example

petstore-cli testEnumParameters enum_header_string_array:value enum_header_string:value  Specify as:  enum_query_string_array="value1,value2,..."  enum_query_string=value  enum_query_integer=value  enum_query_double=value

Parameters

Name Type Description Notes
enumHeaderStringArray array[string] Header parameter enum test (string array) [optional] [default to null]
enumHeaderString string Header parameter enum test (string) [optional] [default to -efg]
enumQueryStringArray array[string] Query parameter enum test (string array) [optional] [default to null]
enumQueryString string Query parameter enum test (string) [optional] [default to -efg]
enumQueryInteger integer Query parameter enum test (double) [optional] [default to null]
enumQueryDouble float Query parameter enum test (double) [optional] [default to null]
enumFormStringArray array[string] Form parameter enum test (string array) [optional] [default to $]
enumFormString string Form parameter enum test (string) [optional] [default to -efg]

Return type

(empty response body)

Authorization

No authorization required

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]

testGroupParameters

Fake endpoint to test group parameters (optional)

Fake endpoint to test group parameters (optional)

Example

petstore-cli testGroupParameters  required_string_group=value required_boolean_group:value  required_int64_group=value  string_group=value boolean_group:value  int64_group=value

Parameters

Name Type Description Notes
requiredStringGroup integer Required String in group parameters [default to null]
requiredBooleanGroup boolean Required Boolean in group parameters [default to null]
requiredInt64Group integer Required Integer in group parameters [default to null]
stringGroup integer String in group parameters [optional] [default to null]
booleanGroup boolean Boolean in group parameters [optional] [default to null]
int64Group integer Integer in group parameters [optional] [default to null]

Return type

(empty response body)

Authorization

No authorization required

HTTP request headers

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

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

testInlineAdditionalProperties

test inline additionalProperties

Example

petstore-cli testInlineAdditionalProperties

Parameters

Name Type Description Notes
param map[String, string] request body

Return type

(empty response body)

Authorization

No authorization required

HTTP request headers

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

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

testJsonFormData

test json serialization of form data

Example

petstore-cli testJsonFormData

Parameters

Name Type Description Notes
param string field1 [default to null]
param2 string field2 [default to null]

Return type

(empty response body)

Authorization

No authorization required

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]