OpenAPITools / OpenAPITools/openapi-generator
[BUG] unexpected generated code when override security scheme on swagger2.0
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
I encountered a problem that a unexpected code was generated when override security schema on swagger2.0.
In the yaml example below, the authentication code for both APIs were generated.
Also, I checked a variable authMethods in template. And its value was unexpected.
openapi-generator version
openapi-generator-cli 5.0.0-SNAPSHOT
commit : 54b37c6
built : 2020-08-03T07:20:03Z
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
OpenAPI declaration file content or url
swagger: "2.0"
info:
title: title
version: 0.0.1
description: description
securityDefinitions:
Token:
type: apiKey
in: header
name: Authorization
security:
- Token: []
paths:
/user:
get:
responses:
200:
description: description
/signin:
get:
security: []
responses:
200:
description: description
Generation Details
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:latest generate \
--generator-name php \
--input-spec /local/openapi.yaml \
--output /local/output_php
Steps to reproduce
same as Generation Details
Related issues/PRs
none
Suggest a fix
none
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 with /local/openapi.yaml and the PHP generation command, then inspect how the template's authMethods handles the operation with security: []. Done means /signin generates no authentication code while /user still does; verify the generated output against the reported behavior and add a regression test if an existing generator test entry point is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100