Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Http signature authentication test to fake petstore spec #6054

Merged
merged 2 commits into from
Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/openapi-generator-maven-plugin/examples/spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.2.2-SNAPSHOT</version>
<version>4.3.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,32 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HealthCheckResult'
/fake/http-signature-test:
get:
tags:
- fake
summary: test http signature authentication
operationId: fake-http-signature-test
parameters:
- name: query_1
in: query
description: query parameter
required: optional
schema:
type: string
- name: header_1
in: header
description: header parameter
required: optional
schema:
type: string
security:
- http_signature_test
requestBody:
$ref: '#/components/requestBodies/Pet'
responses:
200:
description: The instance started successfully
servers:
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
Expand Down Expand Up @@ -1168,6 +1194,9 @@ components:
type: http
scheme: bearer
bearerFormat: JWT
http_signature_test:
type: http
scheme: signature
schemas:
Foo:
type: object
Expand Down
16 changes: 16 additions & 0 deletions samples/openapi3/client/petstore/go/go-petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Class | Method | HTTP request | Description
*AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **Patch** /another-fake/dummy | To test special tags
*DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **Get** /foo |
*FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **Get** /fake/health | Health check endpoint
*FakeApi* | [**FakeHttpSignatureTest**](docs/FakeApi.md#fakehttpsignaturetest) | **Get** /fake/http-signature-test | test http signature authentication
*FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **Post** /fake/outer/boolean |
*FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **Post** /fake/outer/composite |
*FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **Post** /fake/outer/number |
Expand Down Expand Up @@ -189,6 +190,21 @@ r, err := client.Service.Operation(auth, args)
```


## http_signature_test

- **Type**: HTTP basic authentication

Example

```golang
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
```


## petstore_auth


Expand Down
32 changes: 32 additions & 0 deletions samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,35 @@ paths:
summary: Health check endpoint
tags:
- fake
/fake/http-signature-test:
get:
operationId: fake-http-signature-test
parameters:
- description: query parameter
explode: true
in: query
name: query_1
required: false
schema:
type: string
style: form
- description: header parameter
explode: false
in: header
name: header_1
required: false
schema:
type: string
style: simple
requestBody:
$ref: '#/components/requestBodies/Pet'
responses:
"200":
description: The instance started successfully
security: []
summary: test http signature authentication
tags:
- fake
components:
requestBodies:
UserArray:
Expand Down Expand Up @@ -2057,3 +2086,6 @@ components:
bearerFormat: JWT
scheme: bearer
type: http
http_signature_test:
scheme: signature
type: http
81 changes: 81 additions & 0 deletions samples/openapi3/client/petstore/go/go-petstore/api_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,87 @@ func (a *FakeApiService) FakeHealthGet(ctx _context.Context) (HealthCheckResult,
return localVarReturnValue, localVarHTTPResponse, nil
}

// FakeHttpSignatureTestOpts Optional parameters for the method 'FakeHttpSignatureTest'
type FakeHttpSignatureTestOpts struct {
Query1 optional.String
Header1 optional.String
}

/*
FakeHttpSignatureTest test http signature authentication
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param pet Pet object that needs to be added to the store
* @param optional nil or *FakeHttpSignatureTestOpts - Optional Parameters:
* @param "Query1" (optional.String) - query parameter
* @param "Header1" (optional.String) - header parameter
*/
func (a *FakeApiService) FakeHttpSignatureTest(ctx _context.Context, pet Pet, localVarOptionals *FakeHttpSignatureTestOpts) (*_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
)

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/fake/http-signature-test"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}

if localVarOptionals != nil && localVarOptionals.Query1.IsSet() {
localVarQueryParams.Add("query_1", parameterToString(localVarOptionals.Query1.Value(), ""))
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json", "application/xml"}

// 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
}
if localVarOptionals != nil && localVarOptionals.Header1.IsSet() {
localVarHeaderParams["header_1"] = parameterToString(localVarOptionals.Header1.Value(), "")
}
// body params
localVarPostBody = &pet
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, 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 := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}

return localVarHTTPResponse, nil
}

// FakeOuterBooleanSerializeOpts Optional parameters for the method 'FakeOuterBooleanSerialize'
type FakeOuterBooleanSerializeOpts struct {
Body optional.Bool
Expand Down
45 changes: 45 additions & 0 deletions samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**FakeHealthGet**](FakeApi.md#FakeHealthGet) | **Get** /fake/health | Health check endpoint
[**FakeHttpSignatureTest**](FakeApi.md#FakeHttpSignatureTest) | **Get** /fake/http-signature-test | test http signature authentication
[**FakeOuterBooleanSerialize**](FakeApi.md#FakeOuterBooleanSerialize) | **Post** /fake/outer/boolean |
[**FakeOuterCompositeSerialize**](FakeApi.md#FakeOuterCompositeSerialize) | **Post** /fake/outer/composite |
[**FakeOuterNumberSerialize**](FakeApi.md#FakeOuterNumberSerialize) | **Post** /fake/outer/number |
Expand Down Expand Up @@ -49,6 +50,50 @@ No authorization required
[[Back to README]](../README.md)


## FakeHttpSignatureTest

> FakeHttpSignatureTest(ctx, pet, optional)

test http signature authentication

### Required Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
**optional** | ***FakeHttpSignatureTestOpts** | optional parameters | nil if no parameters

### Optional Parameters

Optional parameters are passed through a pointer to a FakeHttpSignatureTestOpts struct


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------

**query1** | **optional.String**| query parameter |
**header1** | **optional.String**| header parameter |

### Return type

(empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/json, application/xml
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)


## FakeOuterBooleanSerialize

> bool FakeOuterBooleanSerialize(ctx, optional)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Class | Method | HTTP request | Description
*AnotherFakeApi* | [**call123TestSpecialTags**](docs/Api/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
*DefaultApi* | [**fooGet**](docs/Api/DefaultApi.md#fooget) | **GET** /foo |
*FakeApi* | [**fakeHealthGet**](docs/Api/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
*FakeApi* | [**fakeHttpSignatureTest**](docs/Api/FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
Expand Down Expand Up @@ -214,6 +215,11 @@ Class | Method | HTTP request | Description



## http_signature_test




## petstore_auth


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
[**fakeHttpSignatureTest**](FakeApi.md#fakeHttpSignatureTest) | **GET** /fake/http-signature-test | test http signature authentication
[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
Expand Down Expand Up @@ -71,6 +72,63 @@ No authorization required
[[Back to README]](../../README.md)


## fakeHttpSignatureTest

> fakeHttpSignatureTest($pet, $query_1, $header_1)

test http signature authentication

### Example

```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');


$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
$query_1 = 'query_1_example'; // string | query parameter
$header_1 = 'header_1_example'; // string | header parameter

try {
$apiInstance->fakeHttpSignatureTest($pet, $query_1, $header_1);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeHttpSignatureTest: ', $e->getMessage(), PHP_EOL;
}
?>
```

### Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
**query_1** | **string**| query parameter | [optional]
**header_1** | **string**| header parameter | [optional]

### Return type

void (empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/json, application/xml
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../../README.md#documentation-for-models)
[[Back to README]](../../README.md)


## fakeOuterBooleanSerialize

> bool fakeOuterBooleanSerialize($body)
Expand Down
Loading