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

Update code generated by Swagger code-gen

I have generated the code from swagger.yaml file using swagger code-gen in spring. Now I have updated the swagger.yaml file for my API and added few more HTTP operations. Will it be possible to update the existing code generated previously…
Chandresh Mishra
  • 1,081
  • 3
  • 24
  • 45
8
votes
1 answer

Swagger - how to use swagger-codegen and build a project on the long term

The Swagger project is wonderful to create easily client and server apps in every language, but I don't understand how to maintain or extend an existing project in a proper way. I'm generating a Java server - language parameter is jaxrs-spec. I…
freedev
  • 25,946
  • 8
  • 108
  • 125
8
votes
2 answers

swagger-codegen client: How to include jackson annotations on models

I'm using swagger-codegen to generate a rest client, but I get a problem, the service I'm consuming returns a model with an inheritance, the API model looks like this: public class Person { private List books; ... } @JsonTypeInfo(use…
satellite satellite
  • 893
  • 2
  • 10
  • 27
8
votes
2 answers

Using swagger-codegen with multiple swagger files

Our project uses multiple swagger files for a single API, yet it appears swagger-codegen only accepts one. How do we generate code with swagger-codegen in this case?
LookingToLearn
  • 303
  • 3
  • 8
8
votes
1 answer

How to use Swagger Codegen TypeScript Fetch Client

Has anyone successfully used the Swagger Code Generator to create a TypeScript Fetch client that can be used within the browser? I'm trying to use the generated API client within a React application that uses TypeScript. Although I've successfully…
Sean
  • 293
  • 1
  • 4
  • 10
7
votes
1 answer

How to define alias in OpenApi, eventually using it in Pojo

Let's assume I have this definition in my openapi.yml (this is just a madeup example to depict the issue I have): components: schemas: Address: type: object properties: name: type: string zip: …
7
votes
1 answer

Get stream from file upload in openapi

I have a backend application (Java 8) and an Angular frontend. Now, I added a file upload using multipart/formdata. We use openapi to generate the api code. Here's the part of the code used to generate it: "post": { ... "consumes" : [ …
fhueser
  • 599
  • 3
  • 16
7
votes
3 answers

Swagger codegen to Java Spring generates incorrect file response entity from OpenAPI component of binary format

I am using swagger-codegen-maven-plugin to generate Spring interface from OpenAPI file (OpenAPI 3.0.2) io.swagger.codegen.v3 swagger-codegen-maven-plugin 3.0.14 The response of one…
Matúš Bartko
  • 2,425
  • 2
  • 30
  • 42
7
votes
1 answer

Swagger Codegen basePath is being ignored

I'm trying to generate some web services definitions using Swagger Codegen » 2.2.1 All configs are working and the classes are generate correctly by my .yaml definitions. Why the property basePath is being ignored? My @RestController generate…
7
votes
0 answers

Unable to generate correct swagger for list of enums in scala

When generating swagger documentation for lists of enums in our scala apps, the swagger definitions generated are only empty objects. When generating swagger documentation for enums everything is as expected, it is only when dealing with lists of…
Premer
  • 118
  • 6
7
votes
1 answer

How to inject custom spring validation inside swagger codegen?

We are able to use openApi documentation and generate our Java Input classes using the spring swagger-codegen. Also, we can inject the javax.validation annotations when input is generated for common constraints like length, mandatory etc. I would…
7
votes
0 answers

swagger-codegen react client - experimental syntax 'classProperties' error

I'm trying to generate as swagger es6 client for my react application but I'm running into the following babel error: SyntaxError: /path/to/petstore/src/ApiClient.js: Support for the experimental syntax 'classProperties' isn't currently enabled…
Arthur
  • 2,622
  • 4
  • 28
  • 46
7
votes
1 answer

How to specify line endings (CRLF)

We're using Swagger Codegen 2.4.5 to generate models from our API. Everything is working exactly as we need with one relatively minor exception. We're generating C# models, and as per windows these are typically stored with CRLF line endings.…
Simon Laing
  • 1,194
  • 7
  • 18
7
votes
2 answers

when using swagger codegen getting 'List' instead of simply 'byte[]'

A byte[] is modelled in swagger file as an Array of byte[]. When using swagger codegen we are getting List instead of simply byte[] Swagger.json "document": { "type": "array", "items": { "type": "string", …
user2593400
  • 163
  • 1
  • 1
  • 8
7
votes
1 answer

Make swagger codegen maven plugin access yaml files from another maven dependency

I have an API written in Swagger for which I want to generate both the Service implementation and also the client, and they have to be in separate maven modules. I was thinking of separating them into 3 separate Maven modules (or submodules of the…
jbx
  • 21,365
  • 18
  • 90
  • 144