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
4
votes
2 answers

Install swagger-codegen via npm on Windows OS

I've generated my client typescript/angular2 language using https://github.com/swagger-api/swagger-codegen via a Java Command. But i would like to generate my client typescript/angular2 using an npm command not a java command. Example : npm…
mahdi kallel
  • 453
  • 1
  • 6
  • 15
4
votes
0 answers

swagger java code gen hidden attributes

We are using swagger-codegen-maven-plugin to generate our model classes from spec file. I know we can make a field hidden by using hidden=true in ApiModelProperty. Is there a way this can be set in the spec , so that codegen automatically adds…
basu76
  • 441
  • 10
  • 19
4
votes
1 answer

Changing the name of a generated data model property in swagger-codegen

I am generating a data model using swagger-codegen. The template /// /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} /// {{#description}} ///…
taj
  • 1,128
  • 1
  • 9
  • 23
4
votes
1 answer

Compile generated maven project in generated-sources directory

I am generating a complete maven project (with its own pom.xml) with swagger codegen maven plugin. It outputs the project to generated-sources/swagger/ directory. However java sources in this directory are compiled against dependencies that are…
px5x2
  • 1,495
  • 2
  • 14
  • 29
3
votes
1 answer

How to make a gradle task depends on the "generateOpenApiDocs" task from the springdoc-openapi-gradle-plugin (using Kotlin DSL)?

I'm quite new to gradle, and I would like to automate the following tasks : Generate an openapi.json file from a SpringBoot application (using the springdoc-openapi-gradle-plugin) Then use this generated file to create a client SDK (using the…
3
votes
1 answer

Swagger codegen, custom code and new stub

I am tinkering with Swagger Codegen for Python and the Petstore example. I see that the generated stubs rely on Python libraries (swagger_sever, connexion,...). import connexion import six from swagger_server.models.api_response import ApiResponse …
Luca P.
  • 1,021
  • 8
  • 20
3
votes
0 answers

swagger 2.0 not validating enum in header

I am working on a project that uses Swagger 2.0 to generate an API interface which is then implemented in production code. There is a problem with a parameter that comes from the header. There are 2 desired behaviors - If a value is provided and…
dbrewster
  • 611
  • 7
  • 16
3
votes
1 answer

How to generate java model classes without annotations using openapi-generator-maven-plugin/ swagger?

I want to generate java model classes from yaml file without annotations in generating classes. How it is possible to generate? I tried multiple ways but not able to generate model classes without annotations. Always containing annotations in…
user3094331
  • 532
  • 6
  • 21
3
votes
1 answer

Force Camel case in Swagger Gen for parameters

Problem: I have Rest Endpoint with route params that look something like this [HttpDelete("{id}")] public async Task DeleteDocument([FromRoute] DeleteDocumentRequest request) Where the "DeleteDocumentRequest" has a gettor /…
adova
  • 950
  • 1
  • 8
  • 14
3
votes
1 answer

Swagger - How to add definitions on child objects in c#

In C# (Asp.Net Core) )I have the following documentation over a child object of type NameValue. I wish to have the documentation I added here over FromWarehouse, but when Swagger renders, it uses the definition for NameValue, not FromWarehouse. ///…
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
3
votes
0 answers

OpenAPI Codegen "oneOf": Java classes not generated correctly

TLDR: OpenAPI offers 'oneOf' property. The resulting java classes created do not seem to allow one of the possible instances. Details: I am creating the spring/java server side rest api code using OpenAPI maven plugin. The request class is not such…
zur
  • 1,121
  • 1
  • 11
  • 21
3
votes
1 answer

Remove ResponseEntity in swagger-codegen-maven-plugin api class

I generated api classes with swagger-codegen-maven-plugin, and methods return ResponseEntity @ApiOperation(value = "", nickname = "getBlockingByMdmdId", notes = "", response = BlockingDto.class, tags={ "blocklist", }) @ApiResponses(value = { …
3
votes
3 answers

Swagger generated code date issue "Java 8 date/time type java.time.OffsetDateTime not supported by default"

I have SpringBoot Java (server stub) code generated from a YAML API definition file which I coded in SwaggerHub. I use Open API 3. I cannot get this generated code working, seems quite buggy. The error I cannot fix is this…
peter.petrov
  • 38,363
  • 16
  • 94
  • 159
3
votes
0 answers

How to generate swagger models with empty collection in getters when the collection is null?

I have went through some stack overflow posts and online and can see that the swagger has changed the default from initializing empty collection to null when generating swagger models using maven swagger codegen plugin. So for example if I generate…
happytohelp
  • 305
  • 3
  • 14
3
votes
0 answers

What is Schema.AccessMode.READ_ONLY in Swagger generated Model class

We have a POST API in Spring Boot and there is one Request Body Model class got generated through Swagger CodeGen with OpenApi yaml file. One field is annotated with, @Schema(accessMode = Schema.AccessMode.READ_ONLY) Code snippet: public class…
Surya
  • 604
  • 1
  • 6
  • 25