Skip to content

Commit ef04a00

Browse files
wing328michaelpro1
authored andcommitted
Add Http signature authentication test to fake petstore spec (OpenAPITools#6054)
* add endpoint to test http signature * update plugin version
1 parent fbcf1fe commit ef04a00

File tree

25 files changed

+1064
-2
lines changed

25 files changed

+1064
-2
lines changed

modules/openapi-generator-maven-plugin/examples/spring.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<groupId>org.openapitools</groupId>
2121
<artifactId>openapi-generator-maven-plugin</artifactId>
2222
<!-- RELEASE_VERSION -->
23-
<version>4.2.2-SNAPSHOT</version>
23+
<version>4.3.1-SNAPSHOT</version>
2424
<!-- /RELEASE_VERSION -->
2525
<executions>
2626
<execution>

modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,32 @@ paths:
10931093
application/json:
10941094
schema:
10951095
$ref: '#/components/schemas/HealthCheckResult'
1096+
/fake/http-signature-test:
1097+
get:
1098+
tags:
1099+
- fake
1100+
summary: test http signature authentication
1101+
operationId: fake-http-signature-test
1102+
parameters:
1103+
- name: query_1
1104+
in: query
1105+
description: query parameter
1106+
required: optional
1107+
schema:
1108+
type: string
1109+
- name: header_1
1110+
in: header
1111+
description: header parameter
1112+
required: optional
1113+
schema:
1114+
type: string
1115+
security:
1116+
- http_signature_test
1117+
requestBody:
1118+
$ref: '#/components/requestBodies/Pet'
1119+
responses:
1120+
200:
1121+
description: The instance started successfully
10961122
servers:
10971123
- url: 'http://{server}.swagger.io:{port}/v2'
10981124
description: petstore server
@@ -1168,6 +1194,9 @@ components:
11681194
type: http
11691195
scheme: bearer
11701196
bearerFormat: JWT
1197+
http_signature_test:
1198+
type: http
1199+
scheme: signature
11711200
schemas:
11721201
Foo:
11731202
type: object

samples/openapi3/client/petstore/go/go-petstore/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Class | Method | HTTP request | Description
3535
*AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **Patch** /another-fake/dummy | To test special tags
3636
*DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **Get** /foo |
3737
*FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **Get** /fake/health | Health check endpoint
38+
*FakeApi* | [**FakeHttpSignatureTest**](docs/FakeApi.md#fakehttpsignaturetest) | **Get** /fake/http-signature-test | test http signature authentication
3839
*FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **Post** /fake/outer/boolean |
3940
*FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **Post** /fake/outer/composite |
4041
*FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **Post** /fake/outer/number |
@@ -189,6 +190,21 @@ r, err := client.Service.Operation(auth, args)
189190
```
190191

191192

193+
## http_signature_test
194+
195+
- **Type**: HTTP basic authentication
196+
197+
Example
198+
199+
```golang
200+
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
201+
UserName: "username",
202+
Password: "password",
203+
})
204+
r, err := client.Service.Operation(auth, args)
205+
```
206+
207+
192208
## petstore_auth
193209

194210

samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,35 @@ paths:
11691169
summary: Health check endpoint
11701170
tags:
11711171
- fake
1172+
/fake/http-signature-test:
1173+
get:
1174+
operationId: fake-http-signature-test
1175+
parameters:
1176+
- description: query parameter
1177+
explode: true
1178+
in: query
1179+
name: query_1
1180+
required: false
1181+
schema:
1182+
type: string
1183+
style: form
1184+
- description: header parameter
1185+
explode: false
1186+
in: header
1187+
name: header_1
1188+
required: false
1189+
schema:
1190+
type: string
1191+
style: simple
1192+
requestBody:
1193+
$ref: '#/components/requestBodies/Pet'
1194+
responses:
1195+
"200":
1196+
description: The instance started successfully
1197+
security: []
1198+
summary: test http signature authentication
1199+
tags:
1200+
- fake
11721201
components:
11731202
requestBodies:
11741203
UserArray:
@@ -2057,3 +2086,6 @@ components:
20572086
bearerFormat: JWT
20582087
scheme: bearer
20592088
type: http
2089+
http_signature_test:
2090+
scheme: signature
2091+
type: http

samples/openapi3/client/petstore/go/go-petstore/api_fake.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,87 @@ func (a *FakeApiService) FakeHealthGet(ctx _context.Context) (HealthCheckResult,
101101
return localVarReturnValue, localVarHTTPResponse, nil
102102
}
103103

104+
// FakeHttpSignatureTestOpts Optional parameters for the method 'FakeHttpSignatureTest'
105+
type FakeHttpSignatureTestOpts struct {
106+
Query1 optional.String
107+
Header1 optional.String
108+
}
109+
110+
/*
111+
FakeHttpSignatureTest test http signature authentication
112+
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
113+
* @param pet Pet object that needs to be added to the store
114+
* @param optional nil or *FakeHttpSignatureTestOpts - Optional Parameters:
115+
* @param "Query1" (optional.String) - query parameter
116+
* @param "Header1" (optional.String) - header parameter
117+
*/
118+
func (a *FakeApiService) FakeHttpSignatureTest(ctx _context.Context, pet Pet, localVarOptionals *FakeHttpSignatureTestOpts) (*_nethttp.Response, error) {
119+
var (
120+
localVarHTTPMethod = _nethttp.MethodGet
121+
localVarPostBody interface{}
122+
localVarFormFileName string
123+
localVarFileName string
124+
localVarFileBytes []byte
125+
)
126+
127+
// create path and map variables
128+
localVarPath := a.client.cfg.BasePath + "/fake/http-signature-test"
129+
localVarHeaderParams := make(map[string]string)
130+
localVarQueryParams := _neturl.Values{}
131+
localVarFormParams := _neturl.Values{}
132+
133+
if localVarOptionals != nil && localVarOptionals.Query1.IsSet() {
134+
localVarQueryParams.Add("query_1", parameterToString(localVarOptionals.Query1.Value(), ""))
135+
}
136+
// to determine the Content-Type header
137+
localVarHTTPContentTypes := []string{"application/json", "application/xml"}
138+
139+
// set Content-Type header
140+
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
141+
if localVarHTTPContentType != "" {
142+
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
143+
}
144+
145+
// to determine the Accept header
146+
localVarHTTPHeaderAccepts := []string{}
147+
148+
// set Accept header
149+
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
150+
if localVarHTTPHeaderAccept != "" {
151+
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
152+
}
153+
if localVarOptionals != nil && localVarOptionals.Header1.IsSet() {
154+
localVarHeaderParams["header_1"] = parameterToString(localVarOptionals.Header1.Value(), "")
155+
}
156+
// body params
157+
localVarPostBody = &pet
158+
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
159+
if err != nil {
160+
return nil, err
161+
}
162+
163+
localVarHTTPResponse, err := a.client.callAPI(r)
164+
if err != nil || localVarHTTPResponse == nil {
165+
return localVarHTTPResponse, err
166+
}
167+
168+
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
169+
localVarHTTPResponse.Body.Close()
170+
if err != nil {
171+
return localVarHTTPResponse, err
172+
}
173+
174+
if localVarHTTPResponse.StatusCode >= 300 {
175+
newErr := GenericOpenAPIError{
176+
body: localVarBody,
177+
error: localVarHTTPResponse.Status,
178+
}
179+
return localVarHTTPResponse, newErr
180+
}
181+
182+
return localVarHTTPResponse, nil
183+
}
184+
104185
// FakeOuterBooleanSerializeOpts Optional parameters for the method 'FakeOuterBooleanSerialize'
105186
type FakeOuterBooleanSerializeOpts struct {
106187
Body optional.Bool

samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
55
Method | HTTP request | Description
66
------------- | ------------- | -------------
77
[**FakeHealthGet**](FakeApi.md#FakeHealthGet) | **Get** /fake/health | Health check endpoint
8+
[**FakeHttpSignatureTest**](FakeApi.md#FakeHttpSignatureTest) | **Get** /fake/http-signature-test | test http signature authentication
89
[**FakeOuterBooleanSerialize**](FakeApi.md#FakeOuterBooleanSerialize) | **Post** /fake/outer/boolean |
910
[**FakeOuterCompositeSerialize**](FakeApi.md#FakeOuterCompositeSerialize) | **Post** /fake/outer/composite |
1011
[**FakeOuterNumberSerialize**](FakeApi.md#FakeOuterNumberSerialize) | **Post** /fake/outer/number |
@@ -49,6 +50,50 @@ No authorization required
4950
[[Back to README]](../README.md)
5051

5152

53+
## FakeHttpSignatureTest
54+
55+
> FakeHttpSignatureTest(ctx, pet, optional)
56+
57+
test http signature authentication
58+
59+
### Required Parameters
60+
61+
62+
Name | Type | Description | Notes
63+
------------- | ------------- | ------------- | -------------
64+
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
65+
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
66+
**optional** | ***FakeHttpSignatureTestOpts** | optional parameters | nil if no parameters
67+
68+
### Optional Parameters
69+
70+
Optional parameters are passed through a pointer to a FakeHttpSignatureTestOpts struct
71+
72+
73+
Name | Type | Description | Notes
74+
------------- | ------------- | ------------- | -------------
75+
76+
**query1** | **optional.String**| query parameter |
77+
**header1** | **optional.String**| header parameter |
78+
79+
### Return type
80+
81+
(empty response body)
82+
83+
### Authorization
84+
85+
No authorization required
86+
87+
### HTTP request headers
88+
89+
- **Content-Type**: application/json, application/xml
90+
- **Accept**: Not defined
91+
92+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
93+
[[Back to Model list]](../README.md#documentation-for-models)
94+
[[Back to README]](../README.md)
95+
96+
5297
## FakeOuterBooleanSerialize
5398

5499
> bool FakeOuterBooleanSerialize(ctx, optional)

samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Class | Method | HTTP request | Description
8686
*AnotherFakeApi* | [**call123TestSpecialTags**](docs/Api/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
8787
*DefaultApi* | [**fooGet**](docs/Api/DefaultApi.md#fooget) | **GET** /foo |
8888
*FakeApi* | [**fakeHealthGet**](docs/Api/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
89+
*FakeApi* | [**fakeHttpSignatureTest**](docs/Api/FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication
8990
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
9091
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
9192
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
@@ -214,6 +215,11 @@ Class | Method | HTTP request | Description
214215

215216

216217

218+
## http_signature_test
219+
220+
221+
222+
217223
## petstore_auth
218224

219225

samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
55
Method | HTTP request | Description
66
------------- | ------------- | -------------
77
[**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
8+
[**fakeHttpSignatureTest**](FakeApi.md#fakeHttpSignatureTest) | **GET** /fake/http-signature-test | test http signature authentication
89
[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
910
[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
1011
[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
@@ -71,6 +72,63 @@ No authorization required
7172
[[Back to README]](../../README.md)
7273

7374

75+
## fakeHttpSignatureTest
76+
77+
> fakeHttpSignatureTest($pet, $query_1, $header_1)
78+
79+
test http signature authentication
80+
81+
### Example
82+
83+
```php
84+
<?php
85+
require_once(__DIR__ . '/vendor/autoload.php');
86+
87+
88+
$apiInstance = new OpenAPI\Client\Api\FakeApi(
89+
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
90+
// This is optional, `GuzzleHttp\Client` will be used as default.
91+
new GuzzleHttp\Client()
92+
);
93+
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
94+
$query_1 = 'query_1_example'; // string | query parameter
95+
$header_1 = 'header_1_example'; // string | header parameter
96+
97+
try {
98+
$apiInstance->fakeHttpSignatureTest($pet, $query_1, $header_1);
99+
} catch (Exception $e) {
100+
echo 'Exception when calling FakeApi->fakeHttpSignatureTest: ', $e->getMessage(), PHP_EOL;
101+
}
102+
?>
103+
```
104+
105+
### Parameters
106+
107+
108+
Name | Type | Description | Notes
109+
------------- | ------------- | ------------- | -------------
110+
**pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
111+
**query_1** | **string**| query parameter | [optional]
112+
**header_1** | **string**| header parameter | [optional]
113+
114+
### Return type
115+
116+
void (empty response body)
117+
118+
### Authorization
119+
120+
No authorization required
121+
122+
### HTTP request headers
123+
124+
- **Content-Type**: application/json, application/xml
125+
- **Accept**: Not defined
126+
127+
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints)
128+
[[Back to Model list]](../../README.md#documentation-for-models)
129+
[[Back to README]](../../README.md)
130+
131+
74132
## fakeOuterBooleanSerialize
75133

76134
> bool fakeOuterBooleanSerialize($body)

0 commit comments

Comments
 (0)