OpenAPITools / OpenAPITools/openapi-generator
Generated swagger url definition yaml throws Security requirements must match a security definition
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I am using api.yaml file which is being used to generate. the generated swagger url json doesn't have securityschemes. I tried pasting the json content into swagger editor and see Security requirements must match a security definition
openapi-generator version
OpenAPI declaration file content or url
This is defined yaml under resource folder
openapi: 3.0.2
info:
title: APIs
description: 'Policy APIs for manage Policy Sets, authorization policies, authentication policies, and policy elements.'
version: 1.0.0
license:
name: Apache 2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
contact:
email: sbc@gmail.com
servers:
- url: 'https://{server}/v1/policy'
variables:
server:
default: localhost
description: The host where the API is rooted
security: - BasicAuth: []
paths:
/device-admin/command-sets:
parameters:-
$ref: '#/components/parameters/XRequestIdHeader'
get:
summary: Device Admin - Return list of command sets.
description: Device Admin - Return list of command sets.
operationId: getDeviceAdminCommandSets
tags:- Device Administration - Command Set
responses:
'200':
description: list of commands set
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CommandSet'
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
components:
securitySchemes:
BasicAuth:
type: http
scheme: basic
parameters:
XRequestIdHeader:
in: header
name: X-Request-ID
description: 'request Id, will return in the response headers, and appear in logs'
schema:
type: string
required: false
responses:
BadRequest:
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
NotFound:
description: The specified resource was not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example: '{code: 404, message: The specified resource was not found}'
schemas:
CommandSet:
type: object
required: - name
properties:
name:
type: string
example: DenyAllCommands
description: Command used in Device Admin authorization policies
id:
type: string
format: uuid
Error:
type: object
properties:
code:
type: string
example: 400
message:
type: string
example: Bad Request - Device Administration - Command Set
-
This is generated json converted yaml
openapi: 3.0.3
info:
title: Test YAML
version: 1.0.0
servers:
- url: 'localhost'
description: Inferred Url
tags: - name: device-controller
description: the device API - name: api-controller
description: API
paths:
/api/device:
get:
tags:
- ABCD
summary: Device SUMMARY.
description: Device DESCRIPTION.
operationId: getDevice
parameters:
- name: X-Request-ID
in: header
description: 'request Id, will return in the response headers, and appear in logs'
required: false
schema:
type: string
responses:
'200':
description: list of commands set
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CommandSet'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: The specified resource was not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- BasicAuth: []
components:
schemas:
CommandSet:
title: CommandSet
required:
- name
type: object
properties:
id:
type: string
format: uuid
example: 07da6fd8-5abc-4dc4-bcec-df309d123d17
name:
type: string
example: Deny
Error:
title: Error
type: object
properties:
code:
type: string
example: '400'
message:
type: string
example: Bad Request
I see securitySchemes component is missed in the generated definition json. Please let me know if i am doing something wrong
Suggest a fix/enhancement
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the supplied source YAML with the generated definition shown in the issue, then validate both in Swagger Editor. The issue does not identify a generator, configuration, source file, or test; done would require reproducing the missing components.securitySchemes entry and the resulting BasicAuth validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100