swagger-api / swagger-api/swagger-codegen
Some strings get converted to a number (bug)
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Some strings get converted to a number when running swagger-codegen. For example, the following
phone_number_param_number:
type: object
properties:
number:
type: string
required: true
description: The phone number in E164 format.
example: !!str "+15558675309"
will become
phone_number_param_number:
type: object
properties:
number:
type: string
required: true
description: The phone number in E164 format.
example: +15558675309
which is interpreted by most YAML parsers as the positive number 15558675309.
Swagger-codegen version
3.0.33
3.0.34
3.0.35
Swagger declaration file content or url
phone_number_param_number:
type: object
properties:
number:
type: string
required: true
description: The phone number in E164 format.
example: !!str "+15558675309"
Command line used for generation
docker run -v (pwd):/local swagger-codegen-cli-v3 generate -i /local/index.yaml -l openapi-yaml -o /local/combined
Steps to reproduce
Run the above command on a YAML file which includes a string field with value "+15558675309".
Related issues/PRs
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 with the swagger-codegen-cli-v3 generate entry point and the YAML handling used by the openapi-yaml generator. Reproduce the issue with index.yaml and the supplied command, then verify that the quoted phone-number example remains a string in the generated YAML rather than becoming an unquoted number.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, yaml
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100