OpenAPITools / OpenAPITools/openapi-generator

[BUG] Options are not parsed correctly

Open
#3,874 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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?
    • 4.1.2-SNAPSHOT
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

From #japanese slack channel:
https://openapi-generator.slack.com/archives/CLTHWFBEJ/p1566966541003500

--type-mappings object=Dict[str, Any],string=String

The parameter above is not parsed correctly.

Expect:

  • object=Dict[str, Any]
  • string=String

Actual:

  • object=Dict[str
  • Any]
  • string=String

It's due to the splitCommaSeparatedList implementation that just split by comma:

https://github.com/OpenAPITools/openapi-generator/blob/046db19a8590f3557ae1e04be75792bbeb39cb69/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/OptionUtils.java#L54-L57

openapi-generator version

4.1.2-SNAPSHOT

Command line used for generation
openapi-generator \
generate \
 --input-spec openapi.yaml \
 --generator-name python \
 --output /local/out \
 --type-mappings object=Dict[str, Any]
Suggest a fix
  • Improve the parsing implementation to respect symbols ([], <>)
  • or use parsing library that satisfy the requirement

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/OptionUtils.java at the linked splitCommaSeparatedList implementation. Reproduce the issue with the documented openapi-generator command and type mapping, then verify that values containing brackets or angle brackets remain intact while separate mappings are still parsed separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.