Description
Hi Team
I am really not sure if its a Bug or new feature or I am missing anything.
I have defined the swagger in order to get the authorization token from the response header which can be used for next api call. However when I generate the client code out of swagger, it return only response body as null and not the header. I Have tried all the search but nothing was helpful.
Technology: Spring boot
Note: I have already raised the issue here but they asked me to raise under right repository. Link for the initial issue: OAI/OpenAPI-Specification#2815
Part of the swagger definition,
/token':
post:
tags:
- Token
parameters:
- $ref: '#/components/parameters/Authorization'
description: Used to generate token to call other api
operationId: generateToken
responses:
'200':
description: OK
headers:
authorization:
schema:
$ref: '#/components/securitySchemes/BearerAuth'
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
parameters:
Authorization:
in: header
name: Authorization
description: Bearer token to access the one view API's.
schema:
type: string
required: true
Moreover, there is no response for this api, so the generated client api is throwing exception at catch block since return value is null. how can that be fixed?
try {
return CompletableFuture.completedFuture(
null
);
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
My sample client generator config,
version used :
openapi.generator.version :4.3.1
<generatorName>java</generatorName>
<library>native</library>
<output>${project.basedir}</output>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>true</generateSupportingFiles>
<apiPackage>XYZ</apiPackage>
<invokerPackage>XYZ</invokerPackage>
<modelPackage>XYZ</modelPackage>
<addCompileSourceRoot>true</addCompileSourceRoot>
<configOptions>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<delegatePattern>true</delegatePattern>
<useBeanValidation>true</useBeanValidation>
<performBeanValidation>true</performBeanValidation>
<configPackage>XYZ</configPackage>
<interfaceOnly>true</interfaceOnly>
<sortParamsByRequiredFlag>false</sortParamsByRequiredFlag>
<debugOperations>true</debugOperations>
<debugModels>true</debugModels>
<debugOpenAPI>true</debugOpenAPI>
<asyncNative>true</asyncNative>
<debugSupportingFiles>true</debugSupportingFiles>
</configOptions>
</configuration>
</execution>
Please guide to resolve the issue as its blocking my work