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

How to use Swagger Codegen with .net core

I am able to integrate the Swagge UI in my web api using Swashbuckle. I also want to explore the swagger codegen feature. Can somebody help in - how I can integrate swagger codegen into my web api project? Or do I need to download any tool? I want…
arpymastro
  • 751
  • 3
  • 16
  • 34
11
votes
2 answers

OpenAPI / Swagger 3.0: Default discriminator value

How do you set a default discriminator for each child class? For example, take this schema: components: schemas: Pet: type: object required: - petType properties: petType: type: string …
11
votes
3 answers

Swagger C# Enum generation - underlying int values do not match the original enum

I created an enum on my server with integer values set manually rather than the default increment up from 0 public enum UserType { Anonymous = 0, Customer = 10, Technician = 21, Manager = 25, Primary = 30 } My server is running…
Adam Diament
  • 4,290
  • 3
  • 34
  • 55
11
votes
1 answer

How to use Swagger Codegen in Gradle for OpenAPI 3.0?

I have an OpenAPI 3.0 spec (in YAML format), and would like to generate Java code for the API. I want to do this as part of an automated build (preferably using Gradle), so I can create the service interface, and the implementation of the interface…
robjwilkins
  • 5,462
  • 5
  • 43
  • 59
11
votes
1 answer

Generate static Javascript client from Swagger for use in React Native

I'm building a React Native app that will consume an API with Swagger 2.0 definition. I went to Swagger's repo at https://github.com/swagger-api/swagger-codegen#where-is-javascript and it points to their Javascript generator at…
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
11
votes
3 answers

How to generate Swagger codegen Java models as JPA Entities

I am using Swagger codegen to create Java models to be used in a Spring REST server, and would like to know how to get Swagger to declare each model as a JPA entity. I generate the code with the swagger-codegen-maven-plugin as follows:
Brady
  • 10,207
  • 2
  • 20
  • 59
11
votes
2 answers

Is there a way to generate a swagger specification file from C++ code?

I've a requirement to create a HTTP API layer over a legacy API interface written in C++. My plan is to generate the Swagger or open API file and then make it available to bunch of projects that needs to write a client (who will be consumer of new…
mahesh kamath
  • 195
  • 3
  • 11
11
votes
3 answers

How to specify OpenAPI for binary download in angular

I have a method to download a binary file. This currently has the following spec in openapi.yaml: /processing/getZippedReports: post: tags: - ProcessingRest description: Get the reports operationId: getZippedReports …
Alex R
  • 808
  • 2
  • 10
  • 26
11
votes
2 answers

Swagger-Codegen: How do I consolidate all files into one file for Client-Code-Generation

I’ve just got started with Swagger and NodeJS. I was able to implement Swagger to my NodeExpress application and was also able to generate typescript-client-code with Swagger-Codegen (Typescript-Angular) to be exact. One problem that I have is the…
Chau Tran
  • 4,668
  • 1
  • 21
  • 39
11
votes
2 answers

Compile-time OK, run-time error while using class from namespace in typescript with webpack

I use swagger-codegen with the -l typescript-angular option to generate a library of REST consumer services. The generated code looks like this (DefaultApi.ts): namespace API.Client { 'use strict'; export class DefaultApi { …
AndyPerlitch
  • 4,539
  • 5
  • 28
  • 43
10
votes
2 answers

Specify content-type for files in multipart/form-data for Swagger

I have implemented endpoint with this signature [HttpPost("Test")] public IActionResult MyTest([Required] IFormFile pdf, [Required] IFormFile image) { // some stuff... return Ok(); } this generates following entry in swagger.json (the…
Matěj Pokorný
  • 16,977
  • 5
  • 39
  • 48
10
votes
1 answer

How to open Swagger-ui from vert.x

I want to implement Swagger-UI in Vert.X app. I have listed all routes and I want to see them in swagger-ui like in SpringBoot. I have also manually edited them in swagger-editor. So, how to open localhost:8080/swagger-ui.html from vert.x app and…
xmlParser
  • 1,903
  • 4
  • 19
  • 48
10
votes
1 answer

Generate code for multiple swaggers in the same project

How do i generate code for multiple swagger files from within the same module/project in one pom.xml. In my application client had provided a swagger and we have one of the backend API to be called for which they provided swagger. I want to generate…
rajanikanth
  • 123
  • 1
  • 2
  • 8
10
votes
1 answer

Integrating Swagger/OpenAPI generated python server with existing Flask application

I am interested in integrating a swagger-codegen generated Python server with an existing Flask application. swagger-codegen generates a Python implementation based on the Connexion library from a Swagger API specification. The examples I have…
user650881
  • 2,214
  • 19
  • 31
10
votes
2 answers

Swagger-Codegen custom settings

I am using swagger-codegen to generate my client-side C# classes. It does the job, but there are a few things I'd like to customize: 1) Most importantly, how I tell it which namespace, or perhaps base namespace, to use? Right now all of the genned…
Serj Sagan
  • 28,927
  • 17
  • 154
  • 183
1 2
3
65 66