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

How to generate OAS yaml file from sources annotations using swagger 3.x?

I've spend hours on searching how to generate the OAS spec yaml file using swagger codegen in Java and I give up. I'd like to provide all API spec data within the Java source as a code annotations. It would be great to expose it via maven. AFAIK I…
3
votes
1 answer

How do I turn off the verbose logging in swagger-codegen?

I upgraded to swagger-codegen 3.0.10, and all of a sudden there's a ton of debugging output to the screen. There seems to be no command-line option to turn it off. Does anyone know how to turn off the debugging output?
BooTooMany
  • 1,192
  • 12
  • 19
3
votes
1 answer

API client in Javascript

I need a little help to solve a problem in my project. Scenario: First: I have a SPA web site that is being developed in Vue.js. Second: I also have a Web API spec in Swagger that I want to use to generate my client code in Javascript. Lastly: I'm…
andercruzbr
  • 454
  • 2
  • 10
3
votes
0 answers

How to enable csrf support for swagger-ui and swagger-codegen

I have an application which is built using Spring Boot and Angular 6. I have also generated API clients using Swagger-codegen. Everything was working fine but recently it was found that application was vulnerable to CSRF. So, I have implemented the…
Rajat Garg
  • 542
  • 2
  • 11
  • 26
3
votes
0 answers

Can I let swagger-codegen ignore some method parameters

I use swagger-codegen in my maven build to generate the Java interfaces for my REST layer. This works very well. However, there are a couple of parameters that I would like to exclude from the generated method's argument list. Question Is it…
neXus
  • 2,005
  • 3
  • 29
  • 53
3
votes
2 answers

How to specify empty string value as default in open api specification for an attribute of type string

I have a open api yaml file like below. I want to assign empty string value as default to string type property. What is the way to do this Test: type: object required: ['', ''] properties: test1: type: string default: " "
3
votes
2 answers

Error when updating Angular 7 -> Angular 8

A month ago I started a Angular 7 project. Now I need to include Angular Material into the project and npm i it. It recently came out in a version 8 which seems incompatible with Angular 7. So I started updating Angular 7 → Angular 8: ng update…
olefrank
  • 6,452
  • 14
  • 65
  • 90
3
votes
1 answer

Using specific properties while referencing to schema

I'm using swagger 2.0 and I have the following schema(definition) : "User": { "type": "object", "properties": { "firstName": { "type": "string", "example": "Tom" }, "lastName": { …
Ayoub k
  • 7,788
  • 9
  • 34
  • 57
3
votes
1 answer

C# Swagger Generation for enum with default value

I have the api looks like the following: public Task GetAsync([FromRoute] string id, [FromQuery] Query select = Query.All) For querys we only want to allow certain properties, listed in the Query enum as below: public enum…
Yituo
  • 1,458
  • 4
  • 17
  • 26
3
votes
0 answers

Swagger codegen - change the way API Class name are generated

I have a swagger.json file automatically generated by Swagger for .NetCore (C#). In this Json file we can find our DTOs placed in the "definitions" section. Our Class name are construct with this template "CompanyName.DTO.ViewMode.AClassName" e.g.…
Waldo
  • 1,070
  • 1
  • 11
  • 30
3
votes
1 answer

How to define dictionary fields with flask_restplus to be used in go code generated with swagger codegen?

I have used swagger CLI to generate go code to call my flask app. swagger codegen converts fields.Raw type defined with flask_restplus model to *interface{} in go assigning the value to the field with *interface{} type in go returns…
Azadeh Khojandi
  • 3,806
  • 1
  • 30
  • 32
3
votes
0 answers

Swagger - filter the generation of API classes based on tags

I'm using Swagger to generate the API starting from a swagger definition (yaml file). I want to be able to filter which API classes should be generated by using the tags. For example, to generate only the API classes that have "tag1" but not…
bluesony
  • 459
  • 1
  • 5
  • 28
3
votes
1 answer

Mapping between Swagger OpenAPI model and JPA entity

I am trying to map openAPI model(Generated using Swagger codegen) and JPA Entity(Generated from database schema in Hibernate) in my java REST-API, so that I can save received model into database using JPA(hibernate) entity and use model to create…
Developer
  • 493
  • 2
  • 8
  • 19
3
votes
1 answer

Swagger codegen with multiple swagger json

I am trying to generate nodejs client sdk using https://github.com/swagger-api/swagger-codegen Here is the command I use swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l javascript -o ./petstore But for the actual sdk which…
Sandy
  • 2,253
  • 6
  • 24
  • 33
3
votes
1 answer

How do I update RestTemplate to correctly map Java Dates?

I have an issue where my RestTemplate.postForEntity(url, restRequest, RepoResponse.class) call is failing because it can't deserialise dates of the form: 2019-02-01T12:00:00.000-0500 because of the missing colon in the timezone. Based on this…
deworde
  • 2,679
  • 5
  • 32
  • 60