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
6
votes
3 answers

How to set the Bearer token in the Python API client generated by Swagger Codegen 3.x?

I've generated a Python client library for this API by using the online Swagger Codegen at https://generator.swagger.io/. The API uses Bearer authentication: openapi: 3.0.0 ... paths: /sandbox/register: post: ... security: …
Awethon
  • 144
  • 1
  • 9
6
votes
3 answers

remove default implementation while generating code using swagger-codegen maven plugin

I have to generate code from yaml file, in my swagger maven plugin I put : true src/main/java true java8
Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87
6
votes
1 answer

How to run just generate goal from swagger codegen maven plugin

I am using the swagger codegen maven plugin to generate a server stub from a swagger spec. If I run mvn compile then it generates properly and compiles the project. However, sometimes I want to run just the generate. Specifically, I'd like to…
Adam
  • 6,539
  • 3
  • 39
  • 65
6
votes
1 answer

How to use golang echo web framework with swagger-go?

i have setup a web server from existing swagger.yml using go-swagger which already gives me validations and routing for the apis I want to use echo web framework to develop this server futher, Is there a way to integrate these two so that i can use…
ashish singh
  • 6,526
  • 2
  • 15
  • 35
6
votes
0 answers

Swagger-codegen generated model deserialization issues - Unrecognized field "@id"

I am trying to use swagger-codegen generated code to consume my REST service, which is defined in my swagger.json (which is provided on server side by springfox 2.9.0) I am generating api, models, and supporting files. But every time I try to…
kscherrer
  • 5,486
  • 2
  • 19
  • 59
6
votes
1 answer

Swagger codegen failed: missing swagger input or config

I have this json file and I have been trying to create models and API code through swagger codegen. This has not been quiet effective as it throws error. Exception in thread "main" java.lang.RuntimeException: missing swagger input or config! at…
Skaranjit
  • 764
  • 9
  • 26
6
votes
5 answers

Why error in Angular 5 as : has no exported member 'OpaqueToken'.?

I have an Angular 4 application, which I am upgrading to Angular 5. I am getting the following error. ERROR in src/app/application/services/generated/variables.ts(1,10): error TS2305: Module '"..../node_modules/@angular/core/core"' has no…
Partha Sarathi Ghosh
  • 10,936
  • 20
  • 59
  • 84
6
votes
1 answer

Reactjs client for Swagger / OpenAPI API specification

Background Using Swagger Editor, I created a spec for my API. I see that Swagger also provide a "Generate a client" option in their Swagger Editor (probably using Swagger Codegen). Objective I want to generate a client and use it in my React app…
mllm
  • 17,068
  • 15
  • 53
  • 64
6
votes
1 answer

swagger-codegen header parameter for Java REST Client

I am using swagger-codegen for generating a Java REST client for one of my REST APIs. The REST APIs take an optional header parameter. The generated methods in the client have an additional parameter that takes the header. I would like the methods…
Mubin
  • 4,192
  • 3
  • 26
  • 45
5
votes
2 answers

Is there a way to generate source code with Jakarta instead Javax using swagger-codegen

I need to generate spring controller source code using swagger codegen gradle plugin with Jakarta packages but I could not see an option in config to do so I have tried to use below options to generate swagger code: additionalProperties = [ …
jeet427
  • 538
  • 3
  • 16
5
votes
1 answer

Convert swagger format: date-time to LocalDateTime.class

I have a swagger.json specification that I can not change. I'm using swagger-codegen to create a library from my swagger.json like this: $ java -jar swagger-codegen-cli.jar generate -i swagger.json -l java -o . The problem is that in my…
5
votes
2 answers

Empty array not getting picked as default for the defined model in Open API AKA Swagger generated code

While designing the API, I am defining a UserGeo model that contains two fields - domain (string array) and country (string array). An empty List [] should be used in the request body if no value is provided for the domain. But on defining the…
im_bhatman
  • 896
  • 1
  • 18
  • 28
5
votes
2 answers

Wrong serialized LocalDateTime with OpenAPI Generator

I'm using OpenAPI Generator to create a client, but when I trying to make a POST request is serialized the LocalDateTime like a integer array, looks like { "startDate": [ 2019, 11, 13, 0, 0 ], "endDate": [ 2020, 12, 31, 0, 0 ] } I'm waiting for…
5
votes
0 answers

Swagger-Codegen plugin does not generate @Deprecated annotation

I would like to set an annotation @deprecated on the endpoint which is generated by swagger-codegen plugin from a yaml file like: paths: '/debug-endpoint/v1/person/{id}': get: deprecated: true summary: get person info …
Capfish
  • 51
  • 2
5
votes
0 answers

swagger ApiResponse example

I am trying to document an api error response with a example of the json body. I couldn't find an example or a fitting annotation. Playing around with the swagger editor I could at least get something that looks like the result I want to…