Questions tagged [swagger-codegen]

Swagger Code Generator allows the generation of API client libraries, server stubs and documentation by an (Swagger) OpenAPI specification.

Swagger Code Generator allows the generation of API client libraries, server stubs and documentation by an (Swagger) OpenAPI specification.

It can be executed as Maven plugin or directly on the commandline. A wide range of programming languages and various libaries are already supported. Its template engine enables users to add their own generators for other languages or custom implementations.

Use this tag for all questions regarding the generation, its template engine, the usage of the cli.

Useful links

982 questions
16
votes
5 answers

How to generate openAPI code using multiple yaml file

I have two yaml file, customer.yaml and employee.yaml. How do I generate java code from these two yaml file in single project. I'm using gradle, I know the task specification for single yaml but how do I specify multiple yaml. Should I specify…
Nicolas
  • 554
  • 2
  • 11
  • 27
16
votes
2 answers

How to generate constructors in swagger codegen?

The codegen did not generate any constructor. I referred to petstore swagger file, used latest swagger codegen jar file. But only default constructor was generated. It is not generating constructor based on its fields. How to enable it?
a3.14_Infinity
  • 5,653
  • 7
  • 42
  • 66
16
votes
4 answers

Swagger Codegen use existing class

How can I get the swagger codegen to use an existing class instead of creating a new class? Is this possible? For instance I want to use org.springframework.data.domain.Page instead of swagger creating another page class.
Derrops
  • 7,651
  • 5
  • 30
  • 60
16
votes
3 answers

How to generate JSON examples from OpenAPI/Swagger model definition?

I'm building a fuzzer for a REST API that has an OpenAPI (Swagger) definition. I want to test all available path from the OpenAPI definition, generate data to test the servers, analyse responses code and content, and to verify if the responses are…
Youssouf Maiga
  • 6,701
  • 7
  • 26
  • 42
16
votes
1 answer

Hard Coding Api Key value in header when using a Swagger Generated Client

I have written many APIs in C# and created a "Swagger" documentation website using Swashbuckle. For Authenticate REST calls I use an API Key in the header. I created a page that permits to download a specific client for any programming language as…
Luca Natali
  • 349
  • 6
  • 17
16
votes
4 answers

Does anyone use Swagger Codegen or OpenAPI Generator SDKs in Production?

Swagger Code Generator can generate SDKs in many languages (listed below from the Github project page). Does anyone use any of Swagger's auto-generated SDKs in production, both as alpha/beta and as GA, and if so, what organizations and for what…
Grokify
  • 15,092
  • 6
  • 60
  • 81
14
votes
3 answers

Can we generate @JsonFormat on model variable using swagger-generater?

I have a variable in yml file startDate: type:string format:date I'm using swagger-generater to generate java code from yml. It's generating a startDate variable as below @JsonProperty("startDate") private LocalDate startDate = null; But I need…
0190198
  • 1,667
  • 16
  • 23
13
votes
3 answers

How to merge multiple OpenAPI specifications?

I'm digging here around trying to find a solution, how to merge several OpenApi v3 component definitions in one file. Let's imagine a situation: You decided to split your OpenApi into multiple files in different folders. (see image below) Now you…
P. Savrov
  • 1,064
  • 4
  • 17
  • 29
13
votes
1 answer

How to treat a "double" field as "BigDecimal" while generating java code from a swagger?

I am generating pojos from a swagger. The swagger is provided from a third party and can't be changed. I want the "double" fields to be generated as "BigDecimal". How do I customise my code generator in order to achieve this?
Vivek Mecharla
  • 491
  • 1
  • 4
  • 10
13
votes
1 answer

Why I get a metaspace error during my gradle build?

I sometimes get a metaspace error during my gradle build. In my gradle configuration, I am using swagger code-gen to generate a lot of classes (~40). I guess that's probably where the problem comes from. Here is an extract from the build.gradle…
Clemzd
  • 895
  • 2
  • 15
  • 35
13
votes
3 answers

How to generate client code using with swagger-codegen-plugin (maven)?

I need to generate a server stub code in eclipse using with swagger-codegen-plugin (for maven) . can you please help how to do it ? and what configuration needed for that( in pom.xml).
rajesh reddy SR
  • 386
  • 1
  • 3
  • 14
13
votes
2 answers

How to properly use the server stubs generated from a swagger specification?

I'm using Swagger 2.0 and swagger-codegen (actually the swagger-codegen-plugin for Maven) to specify,document and generate an API, with Java as the target language. The project is already setup to build the server stubs (JAX-RS) and documentation,…
lpacheco
  • 976
  • 1
  • 14
  • 27
12
votes
0 answers

Swagger "required" vs "nullable" for codegen

I noticed while generating an API client using the typescript-fetch generator that the generated interfaces designate all properties as nullable, even when not designated as nullable in the swagger/open API definition. Furthermore, the only time…
w.brian
  • 16,296
  • 14
  • 69
  • 118
12
votes
2 answers

C# NSwag and swagger-codegen with Enums

I have a .Net Core v2.1 Web API which uses NSwag to generate its Swagger Json. I have a response model as such - public class LoginResponse { public LoginResult LoginResult { get; set; } } public enum LoginResult { AwaitingEmailConfirmation…
WickedW
  • 2,331
  • 4
  • 24
  • 54
12
votes
1 answer

SWAGGER swagger-codegen configuration

I came across a swagger configuration file like this: { "modelPackage": "aa", "apiPackage": "aa.model", "invokerPackage": "aa.model", "bigDecimalAsString": true, "hideGenerationTimestamp": true, "withXml": false, …
AH1N1
  • 148
  • 1
  • 1
  • 8
1
2
3
65 66