swagger-api / swagger-api/swagger-codegen
[cpprest] JSON format:byte incorrectly converted to ByteArray
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
JSON element with {"type": "string", "format": "byte"} is being translated to unknown type 'ByteArray'. The ByteArray.h file being included as a result fails compilation. It appears like similar problems were fixed for Java, C#, and potentially other libraries.
Swagger-codegen version
2.3.1
Swagger declaration file content or url
"key": {
"description": "key is the key in bytes. An empty key is not allowed.",
"type": "string",
"format": "byte"
},
Command line used for generation
java -jar swagger-codegen-cli.jar generate -l cpprest -i example.yaml -o example/src/
Steps to reproduce
The swagger JSON snippet above results in the following generated C++ snippet:
...
#include "ByteArray.h"
...
/// key is the key in bytes. An empty key is not allowed.
ByteArray getKey() const;
bool keyIsSet() const;
void unsetKey();
void setKey(ByteArray value);
This should probably be just string
Related issues/PRs
Similar issue for Java: https://github.com/swagger-api/swagger-codegen/issues/4824
Similar issue for C#: https://github.com/swagger-api/swagger-codegen/issues/3554
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
Reproduce the issue with the shown swagger-codegen-cli command and the cpprest generator, then trace how a string with format byte becomes the generated ByteArray.h include and accessors. Done means the generated C++ uses string instead of the unknown ByteArray type and compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100