From 761f6e5577dbf97b3566bc8367204d8ee75e7e0f Mon Sep 17 00:00:00 2001 From: Jiri Kuncar <jiri.kuncar@gmail.com> Date: Tue, 7 Jan 2020 16:52:35 +0100 Subject: [PATCH 1/4] [go-experimental] Support aliasing of API keys --- .../src/main/resources/go-experimental/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache index 7d9baf079c2..a7e346e6bfd 100644 --- a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache +++ b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache @@ -242,7 +242,7 @@ func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnT if r.ctx != nil { // API Key Authentication if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { - if auth, ok := auth["{{keyParamName}}"]; ok { + if auth, ok := auth["{{#vendorExtensions.x-lookup}}{{vendorExtensions.x-lookup}}{{/vendorExtensions.x-lookup}}{{^vendorExtensions.x-lookup}}{{keyParamName}}{{/vendorExtensions.x-lookup}}"]; ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key -- GitLab From 639824fab6c3d7438736fb00d6172148ce564052 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar <jiri.kuncar@gmail.com> Date: Wed, 8 Jan 2020 11:25:27 +0100 Subject: [PATCH 2/4] Use {{.}} inside condition --- .../src/main/resources/go-experimental/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache index a7e346e6bfd..7edcdc87fac 100644 --- a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache +++ b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache @@ -242,7 +242,7 @@ func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnT if r.ctx != nil { // API Key Authentication if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { - if auth, ok := auth["{{#vendorExtensions.x-lookup}}{{vendorExtensions.x-lookup}}{{/vendorExtensions.x-lookup}}{{^vendorExtensions.x-lookup}}{{keyParamName}}{{/vendorExtensions.x-lookup}}"]; ok { + if auth, ok := auth["{{#vendorExtensions.x-lookup}}{{.}}{{/vendorExtensions.x-lookup}}{{^vendorExtensions.x-lookup}}{{keyParamName}}{{/vendorExtensions.x-lookup}}"]; ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key -- GitLab From 5d0184d2390b3f14d7dea759786477385eaa40fb Mon Sep 17 00:00:00 2001 From: Jiri Kuncar <jiri.kuncar@gmail.com> Date: Mon, 13 Jan 2020 17:46:20 +0100 Subject: [PATCH 3/4] Use name instead of keyParamName for lookup --- .../resources/go-experimental/api.mustache | 2 +- .../go-petstore/api/openapi.yaml | 106 +++++++++--------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache index 7edcdc87fac..d5452fe72e9 100644 --- a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache +++ b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache @@ -242,7 +242,7 @@ func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnT if r.ctx != nil { // API Key Authentication if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { - if auth, ok := auth["{{#vendorExtensions.x-lookup}}{{.}}{{/vendorExtensions.x-lookup}}{{^vendorExtensions.x-lookup}}{{keyParamName}}{{/vendorExtensions.x-lookup}}"]; ok { + if auth, ok := auth["{{#vendorExtensions.x-lookup}}{{.}}{{/vendorExtensions.x-lookup}}{{^vendorExtensions.x-lookup}}{{name}}{{/vendorExtensions.x-lookup}}"]; ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/api/openapi.yaml b/samples/openapi3/client/petstore/go-experimental/go-petstore/api/openapi.yaml index c5e930efc56..a138e08ef95 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/api/openapi.yaml +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/api/openapi.yaml @@ -54,7 +54,7 @@ paths: requestBody: $ref: '#/components/requestBodies/Pet' responses: - 405: + "405": description: Invalid input security: - petstore_auth: @@ -68,11 +68,11 @@ paths: requestBody: $ref: '#/components/requestBodies/Pet' responses: - 400: + "400": description: Invalid ID supplied - 404: + "404": description: Pet not found - 405: + "405": description: Validation exception security: - petstore_auth: @@ -105,7 +105,7 @@ paths: type: array style: form responses: - 200: + "200": content: application/xml: schema: @@ -118,7 +118,7 @@ paths: $ref: '#/components/schemas/Pet' type: array description: successful operation - 400: + "400": description: Invalid status value security: - petstore_auth: @@ -145,7 +145,7 @@ paths: type: array style: form responses: - 200: + "200": content: application/xml: schema: @@ -158,7 +158,7 @@ paths: $ref: '#/components/schemas/Pet' type: array description: successful operation - 400: + "400": description: Invalid tag value security: - petstore_auth: @@ -188,7 +188,7 @@ paths: type: integer style: simple responses: - 400: + "400": description: Invalid pet value security: - petstore_auth: @@ -211,7 +211,7 @@ paths: type: integer style: simple responses: - 200: + "200": content: application/xml: schema: @@ -220,9 +220,9 @@ paths: schema: $ref: '#/components/schemas/Pet' description: successful operation - 400: + "400": description: Invalid ID supplied - 404: + "404": description: Pet not found security: - api_key: [] @@ -255,7 +255,7 @@ paths: type: string type: object responses: - 405: + "405": description: Invalid input security: - petstore_auth: @@ -292,7 +292,7 @@ paths: type: string type: object responses: - 200: + "200": content: application/json: schema: @@ -310,7 +310,7 @@ paths: description: Returns a map of status codes to quantities operationId: getInventory responses: - 200: + "200": content: application/json: schema: @@ -335,7 +335,7 @@ paths: description: order placed for purchasing the pet required: true responses: - 200: + "200": content: application/xml: schema: @@ -344,7 +344,7 @@ paths: schema: $ref: '#/components/schemas/Order' description: successful operation - 400: + "400": description: Invalid Order summary: Place an order for a pet tags: @@ -364,9 +364,9 @@ paths: type: string style: simple responses: - 400: + "400": description: Invalid ID supplied - 404: + "404": description: Order not found summary: Delete purchase order by ID tags: @@ -388,7 +388,7 @@ paths: type: integer style: simple responses: - 200: + "200": content: application/xml: schema: @@ -397,9 +397,9 @@ paths: schema: $ref: '#/components/schemas/Order' description: successful operation - 400: + "400": description: Invalid ID supplied - 404: + "404": description: Order not found summary: Find purchase order by ID tags: @@ -464,7 +464,7 @@ paths: type: string style: form responses: - 200: + "200": content: application/xml: schema: @@ -488,7 +488,7 @@ paths: format: date-time type: string style: simple - 400: + "400": description: Invalid username/password supplied summary: Logs user into the system tags: @@ -516,9 +516,9 @@ paths: type: string style: simple responses: - 400: + "400": description: Invalid username supplied - 404: + "404": description: User not found summary: Delete user tags: @@ -535,7 +535,7 @@ paths: type: string style: simple responses: - 200: + "200": content: application/xml: schema: @@ -544,9 +544,9 @@ paths: schema: $ref: '#/components/schemas/User' description: successful operation - 400: + "400": description: Invalid username supplied - 404: + "404": description: User not found summary: Get user by user name tags: @@ -571,9 +571,9 @@ paths: description: Updated user object required: true responses: - 400: + "400": description: Invalid user supplied - 404: + "404": description: User not found summary: Updated user tags: @@ -585,7 +585,7 @@ paths: requestBody: $ref: '#/components/requestBodies/Client' responses: - 200: + "200": content: application/json: schema: @@ -652,7 +652,7 @@ paths: type: integer style: form responses: - 400: + "400": description: Someting wrong security: - bearer_test: [] @@ -767,9 +767,9 @@ paths: type: string type: object responses: - 400: + "400": description: Invalid request - 404: + "404": description: Not found summary: To test enum parameters tags: @@ -780,7 +780,7 @@ paths: requestBody: $ref: '#/components/requestBodies/Client' responses: - 200: + "200": content: application/json: schema: @@ -873,9 +873,9 @@ paths: - pattern_without_delimiter type: object responses: - 400: + "400": description: Invalid username supplied - 404: + "404": description: User not found security: - http_basic_test: [] @@ -897,7 +897,7 @@ paths: $ref: '#/components/schemas/OuterNumber' description: Input number as post body responses: - 200: + "200": content: '*/*': schema: @@ -916,7 +916,7 @@ paths: $ref: '#/components/schemas/OuterString' description: Input string as post body responses: - 200: + "200": content: '*/*': schema: @@ -935,7 +935,7 @@ paths: $ref: '#/components/schemas/OuterBoolean' description: Input boolean as post body responses: - 200: + "200": content: '*/*': schema: @@ -954,7 +954,7 @@ paths: $ref: '#/components/schemas/OuterComposite' description: Input composite as post body responses: - 200: + "200": content: '*/*': schema: @@ -982,7 +982,7 @@ paths: - param2 type: object responses: - 200: + "200": description: successful operation summary: test json serialization of form data tags: @@ -1000,7 +1000,7 @@ paths: description: request body required: true responses: - 200: + "200": description: successful operation summary: test inline additionalProperties tags: @@ -1023,7 +1023,7 @@ paths: $ref: '#/components/schemas/User' required: true responses: - 200: + "200": description: Success tags: - fake @@ -1034,7 +1034,7 @@ paths: requestBody: $ref: '#/components/requestBodies/Client' responses: - 200: + "200": content: application/json: schema: @@ -1055,7 +1055,7 @@ paths: $ref: '#/components/schemas/FileSchemaTestClass' required: true responses: - 200: + "200": description: Success tags: - fake @@ -1110,7 +1110,7 @@ paths: type: array style: form responses: - 200: + "200": description: Success tags: - fake @@ -1144,7 +1144,7 @@ paths: - requiredFile type: object responses: - 200: + "200": content: application/json: schema: @@ -1160,7 +1160,7 @@ paths: /fake/health: get: responses: - 200: + "200": content: application/json: schema: @@ -1423,14 +1423,14 @@ components: type: integer property: type: string - 123Number: + "123Number": readOnly: true type: integer required: - name xml: name: Name - 200_response: + "200_response": description: Model for testing model name starting with number properties: name: @@ -1608,7 +1608,7 @@ components: type: object List: properties: - 123-list: + "123-list": type: string type: object Client: -- GitLab From d88add548f6152eb33c4c78be1ccf4320de16e9a Mon Sep 17 00:00:00 2001 From: Jiri Kuncar <jiri.kuncar@gmail.com> Date: Wed, 19 Feb 2020 10:27:03 +0100 Subject: [PATCH 4/4] x-lookup to x-auth-id-alias --- .../src/main/resources/go-experimental/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache index 6446b0f5627..96ac8f2d4a6 100644 --- a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache +++ b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache @@ -244,7 +244,7 @@ func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnT if r.ctx != nil { // API Key Authentication if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { - if auth, ok := auth["{{#vendorExtensions.x-lookup}}{{.}}{{/vendorExtensions.x-lookup}}{{^vendorExtensions.x-lookup}}{{name}}{{/vendorExtensions.x-lookup}}"]; ok { + if auth, ok := auth["{{#vendorExtensions.x-auth-id-alias}}{{.}}{{/vendorExtensions.x-auth-id-alias}}{{^vendorExtensions.x-auth-id-alias}}{{name}}{{/vendorExtensions.x-auth-id-alias}}"]; ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key -- GitLab