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
9
votes
0 answers

OpenApi generator doesn't allow multiple schema in content

I've an OpenAPI contract like this: openapi: 3.0.1 info: title: Internal API version: '' tags: - name: Calendar description: Api for Calendar resource paths: '/api/v1/appointments/{id}': get: tags: - Calendar …
drenda
  • 5,846
  • 11
  • 68
  • 141
9
votes
3 answers

Angular 10 Swagger Codegen: Generic type ModuleWithProviders requires 1 type argument(s)

I am generating https://editor.swagger.io/ Codegen proxies. It is giving the following error in Angular 10. How can this be fixed? Generic type 'ModuleWithProviders' requires 1 type argument(s). export class ApiModule { public static…
user13889515
9
votes
1 answer

NSwag: How do you Use Custom Value Object Types in C# -> Swagger -> C# client?

I have an API that uses Noda Time types in both input and output. The types are serialized to strings in the JSON using the default Noda Time serialization format (which basically is the ISO-8601 format). I have an object looking something like…
Mikkel R. Lund
  • 2,336
  • 1
  • 31
  • 44
9
votes
0 answers

Generating an API Client with Swagger OpenAPI 3 with OAuth2 Client Credentials

I am using the Swagger OpenAPI 3.0.2 version for describing my API. I built swagger-codegen 3.0.5 snapshot from the Swagger gihub repo. I want a Java client that will obtain the OAUTH2 token for a grant type of client_credentials. I want client…
Keith
  • 337
  • 3
  • 12
9
votes
1 answer

Swagger-codegen enforcement of "required" fields in Definitions

I have these fields marked as required in my yaml file (swagger spec) MyType: type: object required: - name - amount I am using swagger codegen maven plugin with these…
Kuldeep Jain
  • 8,409
  • 8
  • 48
  • 73
9
votes
2 answers

Generating Java classes for Request and Response objects from Yaml file

We have created a Yaml file using Swagger editor for our APIs specification which includes Base URL, endpoint, Request, Response and Header information etc.. Now I want to implement RESTful web service for these APIs. For that I am thinking of…
Learner
  • 1,503
  • 6
  • 23
  • 44
9
votes
3 answers

"Can't resolve all parameters…" with @Optional decorator

I'm getting a strange DI error. This is a piece of auto-generated code from swagger-codegen - I cannot change it. I'm trying to inject this service. However when I run ng build --aot I get the Can't resolve all parameters... DI error. I tried to…
mode777
  • 3,037
  • 2
  • 23
  • 34
9
votes
1 answer

How do I use the public swagger-generator docker image to generate a client?

We have a fully dockerized web app with a valid Swagger definition for the API. The API runs in its own docker container, and we're using docker-compose to orchestrate everything. I want to generate a Ruby client based on the Swagger definition…
mycargus
  • 2,538
  • 3
  • 23
  • 31
9
votes
3 answers

Swagger Codegen, Maven Plugin: Restrict Server Generation

I want to generate JAX-RS server stubs for my API using the swagger-codegen maven plugin, but I want to use my own service implementation class, instead of the one generated. Is there way to generate everything except this class? For my API, the…
8
votes
2 answers

Swagger Code Gen - package javax.annotation does not exist

Why is swagger-codegen generating project with missing dependencies? Running: java -jar swagger-codegen-cli.jar generate -l java -i swagger.json Generates a project with this for example: @javax.annotation.Generated(value =…
quarks
  • 33,478
  • 73
  • 290
  • 513
8
votes
1 answer

Dynamodb attribute converter provider for enhanced type extending Hashmap

I have a type which is extending HashMap. As per the documentation here, it is possible to add a custom converter for the type. But it seems not working. The contents of the hashMap doesn't get converted, output looks like…
Jimson James
  • 2,937
  • 6
  • 43
  • 78
8
votes
3 answers

Code generation to initialise by default to empty list instead of null

Does Swagger code generation tool have an option for selecting whether the generated classes should have Lists, Maps etc. defaulted to null or empty? Previously, the default was empty, for example private List names = new List. At…
kaskelotti
  • 4,709
  • 9
  • 45
  • 72
8
votes
0 answers

Use Swagger/OpenAPI discriminator so that Jackson serializes object correctly

We're having trouble using the OpenAPI 2.0 discriminator in way that makes both the Swagger tools and the Jackson serializer happy. Problem: during serialization Jackson currently generates two JSON properties for the discriminator, one of them…
Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
8
votes
1 answer

Swagger parameters in query and/or body

Our API has such endpoints that support parameters both from the query and from the body at the same time, by merging those two sets of parameters. For example: /foo?param1=value1 body: { param2=value2 } The resulting set of parameters would…
igr
  • 10,199
  • 13
  • 65
  • 111
8
votes
2 answers

How to generate ASP.NET Core 2 controllers from OpenAPI 3.0 schema?

I have an OpenAPI 3.0 schema YAML document that defines some API endpoints with all the required parameters and responses. Now, I'd like to generate some boilerplate server-side code: the controllers and their methods. My API will be written using…