swagger-api / swagger-api/swagger-codegen
No parameterless constructor is generated for csharp models
@HugoMario is already working on this.
Since May 8, 2020.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I was using Swagger Codegen v.3.0.13 to generate a csharp client from openapi 3.0.1 spec. I noticed that there are no parameterless constructors in the generated models. But they were present when I was using codegen v2x previously for openapis 2x.
I have tried generating the client using the online generator with sample openapi 3.0.1 spec and "codegenVersion" : "v3".
curl -X POST \
https://generator3.swagger.io/api/generate \
-H 'content-type: application/json' \
-d '{
"specURL" : "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml",
"lang" : "csharp",
"type" : "CLIENT",
"codegenVersion" : "V3"
}'
No parameterless constructors are present in models.
Also, I have tried generating the client using the online generator with sample swagger 2.0 spec and "codegenVersion": "v3".
curl -X POST \
https://generator3.swagger.io/api/generate \
-H 'content-type: application/json' \
-d '{
"specURL" : "http://petstore.swagger.io/v2/swagger.json",
"lang" : "csharp",
"type" : "CLIENT",
"codegenVersion" : "V3"
}'
No parameterless constructors are present in models.
But when I generate the client using the online generator with sample swagger 2.0 spec and "codegenVersion": "v2".
curl -X POST \
https://generator3.swagger.io/api/generate \
-H 'content-type: application/json' \
-d '{
"specURL" : "http://petstore.swagger.io/v2/swagger.json",
"lang" : "csharp",
"type" : "CLIENT",
"codegenVersion" : "V2"
}'
Parameterless constructors are present in models.
So it seems like codegen v3 stopped adding parameterless constructors.
Could you tell please whether this is a bug or intended behavior?
Swagger-codegen version
3.0.14
Swagger declaration file content or url
http://petstore.swagger.io/v2/swagger.json
https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
Related issues/PRs
https://github.com/swagger-api/swagger-codegen/issues/2584
https://github.com/swagger-api/swagger-codegen/pull/2802
https://github.com/swagger-api/swagger-codegen/pull/3530
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.
Assessment
This issue has not been assessed yet.