swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.78k stars 6.02k forks source link

No parameterless constructor is generated for csharp models #9895

Open tarbii opened 4 years ago

tarbii commented 4 years ago
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

loaded02 commented 2 years ago

How is the status on this ticket? Is this a bug or intended behavior? Thx