-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update go client, fix double body read (#211)
- Loading branch information
Showing
94 changed files
with
6,796 additions
and
1,702 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
samples/client/petstore-security-test/go/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.3.0-SNAPSHOT | ||
3.0.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: Swagger Petstore */ ' " =end -- \r\n \n \r | ||
description: "This spec is mainly for testing Petstore server and contains fake\ | ||
\ endpoints, models. Please do not use this for any other purpose. Special characters:\ | ||
\ \" \\ */ ' \" =end -- \r\n \n \r" | ||
termsOfService: http://swagger.io/terms/ */ ' " =end -- \r\n \n \r | ||
contact: | ||
email: apiteam@swagger.io */ ' " =end -- \r\n \n \r | ||
license: | ||
name: Apache-2.0 */ ' " =end -- \r\n \n \r | ||
url: http://www.apache.org/licenses/LICENSE-2.0.html */ ' " =end -- \r\n \n \r | ||
version: 1.0.0 */ ' " =end -- \r\n \n \r | ||
externalDocs: | ||
description: Find out more about Swagger */ ' " =end -- \r\n \n \r | ||
url: http://swagger.io | ||
servers: | ||
- url: petstore.swagger.io */ ' " =end -- \r\n \n \r/v2 */ ' " =end -- \r\n \n \r | ||
tags: | ||
- name: fake | ||
description: Everything about your Pets */ ' " =end -- \r\n \n \r | ||
externalDocs: | ||
description: Find out more */ ' " =end -- \r\n \n \r | ||
url: http://swagger.io | ||
paths: | ||
/fake: | ||
put: | ||
tags: | ||
- fake | ||
summary: To test code injection */ ' " =end -- \r\n \n \r | ||
operationId: testCodeInject */ ' " =end -- \r\n \n \r | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
properties: | ||
test code inject */ ' " =end -- \r\n \n \r: | ||
type: string | ||
description: To test code injection */ ' " =end -- \r\n \n \r | ||
? "*/ ' \" =end -- \r\n \n \r" | ||
: schema: | ||
properties: | ||
test code inject */ ' " =end -- \r\n \n \r: | ||
type: string | ||
description: To test code injection */ ' " =end -- \r\n \n \r | ||
responses: | ||
400: | ||
description: To test code injection */ ' " =end -- \r\n \n \r | ||
content: {} | ||
components: | ||
schemas: | ||
Return: | ||
type: object | ||
properties: | ||
return: | ||
type: integer | ||
description: property description */ ' " =end -- \r\n \n \r | ||
format: int32 | ||
description: Model for testing reserved words */ ' " =end -- \r\n \n \r | ||
xml: | ||
name: Return | ||
securitySchemes: | ||
petstore_auth: | ||
type: oauth2 | ||
flows: | ||
implicit: | ||
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog | ||
scopes: | ||
write:pets: modify pets in your account */ ' " =end -- \r\n \n \r | ||
read:pets: read your pets */ ' " =end -- \r\n \n \r | ||
api_key: | ||
type: apiKey | ||
name: api_key */ ' " =end -- \r\n \n \r | ||
in: header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r | ||
* | ||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- | ||
* | ||
* API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r | ||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r | ||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
*/ | ||
|
||
package swagger | ||
|
||
import ( | ||
"io/ioutil" | ||
"net/http" | ||
"net/url" | ||
"strings" | ||
"context" | ||
) | ||
|
||
// Linger please | ||
var ( | ||
_ context.Context | ||
) | ||
|
||
type FakeApiService service | ||
|
||
/* | ||
FakeApiService To test code injection *_/ ' \" =end -- \\r\\n \\n \\r | ||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). | ||
* @param optional nil or *TestCodeInjectEndRnNROpts - Optional Parameters: | ||
* @param "" (optional.Interface of ErrorUnknown) - | ||
*/ | ||
|
||
type TestCodeInjectEndRnNROpts struct { | ||
optional.Interface | ||
} | ||
|
||
func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOptionals *TestCodeInjectEndRnNROpts) (*http.Response, error) { | ||
var ( | ||
localVarHttpMethod = strings.ToUpper("Put") | ||
localVarPostBody interface{} | ||
localVarFileName string | ||
localVarFileBytes []byte | ||
|
||
) | ||
|
||
// create path and map variables | ||
localVarPath := a.client.cfg.BasePath + "/fake" | ||
|
||
localVarHeaderParams := make(map[string]string) | ||
localVarQueryParams := url.Values{} | ||
localVarFormParams := url.Values{} | ||
|
||
// to determine the Content-Type header | ||
localVarHttpContentTypes := []string{"application/json", "*_/ ' =end -- "} | ||
|
||
// set Content-Type header | ||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) | ||
if localVarHttpContentType != "" { | ||
localVarHeaderParams["Content-Type"] = localVarHttpContentType | ||
} | ||
|
||
// to determine the Accept header | ||
localVarHttpHeaderAccepts := []string{} | ||
|
||
// set Accept header | ||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) | ||
if localVarHttpHeaderAccept != "" { | ||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept | ||
} | ||
// body params | ||
if localVarOptionals != nil && localVarOptionals..IsSet() { | ||
|
||
localVarOptional, localVarOptionalok := localVarOptionals..Value().(ErrorUnknown) | ||
if !localVarOptionalok { | ||
return nil, reportError("uNKNOWNBASETYPE should be ErrorUnknown") | ||
} | ||
localVarPostBody = &localVarOptional | ||
} | ||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
localVarHttpResponse, err := a.client.callAPI(r) | ||
if err != nil || localVarHttpResponse == nil { | ||
return localVarHttpResponse, err | ||
} | ||
|
||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) | ||
localVarHttpResponse.Body.Close() | ||
if err != nil { | ||
return localVarHttpResponse, err | ||
} | ||
|
||
|
||
if localVarHttpResponse.StatusCode >= 300 { | ||
newErr := GenericSwaggerError{ | ||
body: localVarBody, | ||
error: localVarHttpResponse.Status, | ||
} | ||
|
||
return localVarHttpResponse, newErr | ||
} | ||
|
||
return localVarHttpResponse, nil | ||
} |
Oops, something went wrong.