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
7
votes
1 answer

swagger.yaml :: How to generate properties with "Long" data type and "Timestamp" datatype?

I am using swagger-codegen-maven-plugin to generate Java classes based on swagger.yaml spec. I have added a property phoneNum in the swagger.yaml as below: phoneNum: type: number I am expecting it generate the property with Integer or Long…
snmaddula
  • 1,111
  • 1
  • 7
  • 21
7
votes
2 answers

How do I swagger generate Kotlin?

I'm trying to generate kotlin code from a swagger json file, and I can't figure out the command-line parameters that should be used. I've tried Swagger codegen v2.3.1 and v2.2.3 and both fail for kotlin, kotlin-client, and kotlin-server with the…
John Kaster
  • 2,509
  • 1
  • 33
  • 40
7
votes
2 answers

Swagger 3.0.0 codegen failed java.lang.RuntimeException: missing swagger input or config

I am specifying my APIs using swagger I was using 2.0 now there is new version 3.0.0 according to the documentation I have specified 3.0.0 specification using offline swagger editor. Once it was ready I downloaded json file using which I am going to…
Prashant
  • 4,474
  • 8
  • 34
  • 82
7
votes
1 answer

Annotation-based Swagger documentation for Vert.x

Is there any annotation based Swagger Documentation creator available for Vert.x yet ? The rest end points are all managed using routers and as such if there is any way available to generate the Swagger documentation, that would be great. I've gone…
7
votes
3 answers

Using swagger-codegen with username and password basic auth

I have a django rest_framework API, Swagger and a Swagger UI. When I am not logged in I can see a very limited view of "login" and "docs". When I am logged in I can see lots of stuff. I am trying to use the swagger-codegen to generate a client: java…
tomsv
  • 7,207
  • 6
  • 55
  • 88
7
votes
2 answers

The specifics of adding a header to an api call with a swagger codegen client in python are unclear

Point out the right document, tutorial, example, or provide one, showing how to add a specific authentication token to a specific header in the Swagger generated API client in Python? Here's what I've tried: My API call works just fine with the…
dlamblin
  • 43,965
  • 20
  • 101
  • 140
7
votes
1 answer

Swagger Codegen JMeter Test data template

I am generating Jmeter's jmx file from a swagger definition, the JMX and test data CSV that gets generated seems pretty useless, it has no parameter information as to what the API expected, no http status code to response mapping information…
Sumit Maingi
  • 2,173
  • 3
  • 24
  • 44
7
votes
2 answers

Swagger CodeGen Https SSL Connectivity

I need to create swagger codegen client for java, javascript pointing to swagger yaml pusblished on https. When tried below command got SSLHandshakeError. "swagger-codegen generate -i https://localhost:443/api/swagger.yaml -l java -o…
erdarun
  • 441
  • 1
  • 8
  • 14
6
votes
0 answers

How to merge multiple Open Api Spec into one using springdoc

I have a micro service architecture with spring cloud gateway and each micro service has its own Open Api Spec. I need to merge all of them into 1 Open Api Spec ( yaml or json ). I am not talking about a single swagger UI serving multiple links. I…
6
votes
1 answer

How to merge multiple OpenAPI 3.0 specification files into one in Maven?

In a Maven project with Spring Boot, there are several OpenAPI 3.0 specification files. One spec defines all HTTP errors (errors.yml), and the components of errors.yml are referenced in other spec. I want to generate an output spec with all…
6
votes
1 answer

How to access request headers on JAXRS classes generated by Swagger Codegen

I have a project with an Swagger API and its server code was generated by swagger-codegen-2.4.24 for language jaxrs. The code generated has an abstract class suffixed "*ApiService" that defines a series of methods, each corresponding to each…
RedEagle
  • 4,418
  • 9
  • 41
  • 64
6
votes
1 answer

How to return different objects for different response codes in Swagger-generated REST API?

I want to respond with different result objects in a Swagger generated API. The type of object is dependent on the result code. But it seems that the Swagger codegen generates only code that allows the first defined/used type to be returned. An…
Kosi2801
  • 22,222
  • 13
  • 38
  • 45
6
votes
0 answers

Python swagger-client for shopware 6

I have generated a Python client via the swagger-codegen-cli (v3) docker image in my GitLab ci pipline for a Shopware 6 shop. The problem I encounter is that every endpoint returns empty data. The strange part is that when I debug the client, I can…
6
votes
1 answer

Swagger-codegen not generating enums as enum type

I have an enum in my swagger scheme which looks like the following: - name: shipmentType in: query required: false type: integer format: int32 enum: - 0 - 1 - 2 - 3 - 4 -…
Mattieeec3
  • 114
  • 3
  • 8
6
votes
1 answer

Why does Swagger Codegen convert an ON/OFF string enum to TRUE/FALSE?

I am using Swagger Codegen 3.0.19, also tried OpenAPI Generator 4.0.3. Java Environment: Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode) Runner: java -jar…
Sannu
  • 1,202
  • 4
  • 21
  • 32