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

How to make the REST service generate a simple string for a Java 8 (Local|Offset)DateTime (when using Swagger)?

Problem: When our REST service returns objects with date/datetime fields, these fields are encoded as complex structures in the JSON format: ... "createdTimestamp": { "offset": { "totalSeconds": 0, "id": "Z", …
5
votes
3 answers

ASP NET Boilerplate > Generating C# swagger client using swagger codegen tool (nswag) not working

I tried generating c# code for and API I created with ASP Net Boilerplate, but the response is not deserializing correctly. Upon investigation, it seems the json response is wrapped using a class called "AjaxResponse"; however, the swagger.json…
Matt
  • 53
  • 3
5
votes
1 answer

swagger-codegen add annotation based on custom property description

I am trying to do something like the following: In my schema JSON models section: "MyObject": { "type": "object", "description": "my description", "properties": { "type": "string", "description": "my property description", …
digable1
  • 61
  • 4
5
votes
2 answers

Generating SQL Server DB from Swagger WebAPI Project

Having found Swagger and generated a WebAPI project for the 'pets' example, I figured the next logical step would be to generate the backend DB. However none of the tutes I've come across recommend an approach for this. I see there are…
Glinkot
  • 2,924
  • 10
  • 42
  • 67
5
votes
2 answers

Swagger avoid removing common prefix

How to skip removing the common prefix from modelsEnum name? I have got an enum with single value (in the future I will have more values) and swagger code gen plugin generates the class with enum CODE instead of AIRPORT_CODE properties: type: …
gauee
  • 305
  • 3
  • 13
5
votes
0 answers

swagger-codegen files location

I am playing with swagger-codegen on a project and I end up asking myself a question: Is there any convention for the location of the swagger files? Here is my case: I'm using Maven for my project, so I have the standard Maven…
Xendar
  • 466
  • 1
  • 6
  • 15
5
votes
1 answer

Mustache: How to downcase first letter

I'm using a mustache template in order to generate some code using Java. I'd like to downcase the first letter of a field. Is there some way to get it? I need to transform it directly. I'm generating C# code. EDIT I'm using Swagger Codegen tool in…
Jordi
  • 20,868
  • 39
  • 149
  • 333
4
votes
1 answer

How do I configure swagger codegen (maven plugin) to return a bad request if one of my enum fields doesn't match?

I'm using the swagger-codegen-maven-plugin 3.0.20 with Java 10. I have these config options true false
Dave
  • 15,639
  • 133
  • 442
  • 830
4
votes
2 answers

In Swagger Code gen, how do i specify required fields when creating a multipart file upload request?

I'm using Java 11 and want to create an OpenAPI 3 request to upload multipart form data (a file and some other fields). I have this in my openApi yml file ... /myobjects/: post: tags: - my-objects summary: Adding…
Dave
  • 15,639
  • 133
  • 442
  • 830
4
votes
0 answers

"swagger-codegen" and "openapi-generator" unintentionally convert a datetime without a time zone to a datetime with UTC time zone

I wrote a parameter that "type:" is "string" and "example:" is a text datetime without time zone like "2021-09-01 00:00:00". but on the UI that was generated by swagger-codegen-cli-3.0.27.jar or openapi-generator-cli-5.2.1.jar, the parameter format…
4
votes
1 answer

ASP.NET Core & Swagger : generate multiple outputs

I'm using ASP.NET Core with Swashbuckle.AspNetCore.SwaggerGen in version v6.1.5. I want routes like [HttpGet] or [HttpGet("user")] in a public swagger.json for public endpoints and other routes that contain internal inside the route like this…
user3079834
  • 2,009
  • 2
  • 31
  • 63
4
votes
2 answers

Package io.swagger.v3.oas.annotations.media does not exist (Swagger Codegen)

I'm generate a java client using swagger codegen cli tool (version 3.0.25) in gradle: task doCodeGenSdk(type: JavaExec) { main = "io.swagger.codegen.v3.Codegen" classpath = configurations.codeGenCli inputs.files…
Alok Nath Saha
  • 297
  • 1
  • 4
  • 20
4
votes
1 answer

Cannot access java.util.function.Predicate

I use swagger to generate code for spring server and try to run with intelliJ. However I got the following error message. Any help is appreciated. java: cannot access java.util.function.Predicate class file for java.util.function.Predicate not…
timo
  • 103
  • 2
  • 12
4
votes
1 answer

How to set a default empty list in swagger codegen

There is an entity with a field cises: type: array description: An array of brands. The length must match the value of the quantity field, or the array must be empty items: type: string Code java …
4
votes
1 answer

swagger-codegen-maven-plugin ignores the importmapping i have set for ZonedDateTime when generating an API class

I am trying to generate an API class from a yaml file using ZonedDateTime as the class for a date. When i do this i can successfully change the generated class OffsetDateTime to ZonedDateTime in the configuration, but the correct import statement is…