Questions tagged [openapi-generator]
An open-source tool to generate API clients, server stubs, documentation and more given an OpenAPI Spec (v2, v3)
1,161
questions
76
votes
3
answers
88k
views
Convert OpenAPI 3.0 to Swagger 2.0
Is there a generator to convert OpenAPI 3.0 to Swagger 2.0?
Mashery, an API gateway, requires Swagger 2.0 format on input to open endpoint.
59
votes
3
answers
34k
views
Is there a way to configure openapi-generator to use jakarta package during generation
I've recently upgraded my project to use spring-boot 3.0.0. So I don't have javax.* modules in the project anymore. But the Open API generator keeps trying to import javax modules. Especially, it uses ...
53
votes
3
answers
26k
views
openapi tools generator vs swagger codegen
I am lost in dependencies and tools:
I previously use the following tool to generate code for my swagger webservices.
swagger-codegen-cli
https://mvnrepository.com/artifact/io.swagger.codegen.v3/...
39
votes
5
answers
45k
views
Use java.time.Instant to represent DateTime instead of OffsetDateTime
I'm using the openApi maven plugin to generate java request/responses for a REST api.
The request has a DateTime property, when I run the generator I get the DateTime property of the attribute ...
32
votes
4
answers
60k
views
How to use OpenAPI "oneOf" property with openapi-generator-maven-plugin when generating Spring code
I am developing an application with an Angular frontend and RESTful Spring Boot Backend
I found this very handy maven plugin openapi-generator-maven-plugin from org.openapitools. With its code ...
27
votes
2
answers
94k
views
Swagger Codegen (with maven plugin) for OpenAPI 3.0
I want to use Swagger Codegen for OpenAPI 3.0 YAML file. And I see Swagger Codegen 3.0.0-rc0 is available. But when I try to use that I run into issues. Following are the details:
My pom.xml file ...
25
votes
5
answers
37k
views
openapi springboot generator jackson no String-argument constructor/factory method to deserialize from String value
I'm using OpenApi SpringBoot generator to generate controller interfaces and models. This creates model classes with JsonNullable<String> for nullable fields. However I'm getting a Jackson type ...
21
votes
3
answers
33k
views
Generating POJOs using OpenAPI generator with Lombok Annotations
I am using OpenAPI generator maven plugin like one below for generating Java client code for models .
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-...
21
votes
5
answers
39k
views
How to skip generation of support and metadata files with openAPI Generator and Maven?
I'm converting a swagger file into an open API v3 one using the openapi-yaml generator with Maven.
What I would like to do is to put the new file directly into some directory.
However some ...
19
votes
1
answer
34k
views
How to define byte array in OpenAPI 3.0
I'm migrating my API from Swagger 2.0 to OpenAPI 3.0. In a DTO I have a field specified as a byte array.
Swagger definition of the DTO:
Job:
type: object
properties:
body:
type: ...
18
votes
5
answers
18k
views
What is the function of springdoc-openapi-maven-plugin configuration/apiDocsUrl?
I'm running the springdoc-openapi-maven-plugin, with the following (standard) configuration:
<plugin>
<groupId>org.springdoc</groupId>
<artifactId&...
17
votes
2
answers
9k
views
Significance of Delegate Design Pattern in Swagger Generated Code?
When i generate code for Spring from my swagger yaml , usually controller layer is generated using delegate pattern , such that for a single model three files are generated . For example , if i ...
17
votes
5
answers
29k
views
How to generate openAPI code using multiple yaml file
I have two yaml file, customer.yaml and employee.yaml. How do I generate java code from these two yaml file in single project. I'm using gradle, I know the task specification for single yaml but how ...
17
votes
7
answers
22k
views
What does the "Unrecognized token openapi" error mean when using OpenAPI Generator with OpenAPI 3.0?
I have written an API definition in the OpenAPI 3.0 format (https://swagger.io/docs/specification/basic-structure/). Now I'm trying to generate Java Spring objects as I was previously doing with a ...
16
votes
2
answers
25k
views
How do I fix OpenAPI error in seemingly correct 'inputSpec' for code generation?
I'm trying to run the OpenAPI generator, but I keep getting an error message that doesn't make sense.
Failed to execute goal org.openapitools:openapi-generator-maven-plugin:5.0.0-SNAPSHOT:generate (...
16
votes
4
answers
17k
views
Does anyone use Swagger Codegen or OpenAPI Generator SDKs in Production?
Swagger Code Generator can generate SDKs in many languages (listed below from the Github project page). Does anyone use any of Swagger's auto-generated SDKs in production, both as alpha/beta and as GA,...
16
votes
2
answers
11k
views
Open API code generator Maven plugin uses old Swagger 2 annotations instead of Swagger 3 annotations
I'm using Open API code generator Maven plugin to generate Open API 3.0 from a file. I'm using this plugin in in my pom.xml:
<groupId>org.openapitools</groupId>
<artifactId>openapi-...
15
votes
4
answers
30k
views
How to omit null field from Swagger/OpenAPI in ResponseEntity?
I'm trying to omit null values in my ResponseEntity.
My controller looks something like this:
@RestController
public class FooController {
//fields
//constructor
@PostMapping
...
15
votes
0
answers
2k
views
What is the proper way to use openapi-generator for generating ktor server stubs
When trying to generate server-side stubs for ktor from openapi, the output to me does not really look very usable.
I set up an example project on Github, where the setup can be reviewed. As I need ...
14
votes
2
answers
14k
views
How to generate an Express + TypeScript API from OpenAPI 3.0 specification?
I wrote specifications for my REST API server using OpenAPI 3.0. Now, instead of manually writing a lot of repetitive code, with all the errors that could be introduced, I'd like to quickly generate ...
14
votes
3
answers
19k
views
How to merge multiple OpenAPI specifications?
I'm digging here around trying to find a solution, how to merge several OpenApi v3 component definitions in one file.
Let's imagine a situation:
You decided to split your OpenApi into multiple files ...
14
votes
1
answer
10k
views
openapi-generator-maven-plugin (Java) does not handle allOf properly
With org.openapitools:openapi-generator-maven-plugin, I have noticed that using allOf composed of multiple objects in a response does not generate a class combining these multiple objects. Instead it ...
13
votes
9
answers
51k
views
HttpMessageNotWritableException: No converter for [...] with preset Content-Type 'null'] with OpenApi Spring generator
I am implementing the petstore API with openAPI in a (gradle) spring boot project. I generate a server with the openapi generator plugin and implement a simple request:
@Service
@RestController
public ...
13
votes
4
answers
8k
views
How can I generate Quarkus rest JX-RS service based on given openapi 3.0.3 yaml file
Currently I am developing an application using quarkus. I have an openapi yaml file that describes everything. I wanted to know if there are quarkus extensions or tool with which I can generate the ...
13
votes
2
answers
6k
views
OpenApi Generator create models with type String instead of Date
Im using OpenApi Generator to create services and models for my angular project.
This is an example of my Json:
"uploadDate" : {
"type" : "string",
...
13
votes
2
answers
16k
views
OpenAPI Generator Pageable with Spring
I would like the OpenAPI Generator (https://github.com/OpenAPITools/openapi-generator) to be able to generate Pageable parameter in API according to the implementation in Spring Boot Data. I've been ...
13
votes
2
answers
19k
views
How to use configuration file (openapitools.json) with @openapitools/openapi-generator-cli?
I use @openapitools/openapi-generator-cli(v2.1.7) to generate the API library on client side.
It works pretty well, except I am not able to format the code generated as I want.
I just noticed there is ...
12
votes
2
answers
5k
views
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:
...
12
votes
0
answers
3k
views
Can OpenAPI integrate HATEOAS in a useful way?
Is it possible to describe a HATEOAS REST API with OpenAPI?
When I describe the API in HAL Format I would need to define three schemas for it (one for Request Payloads, one for Collection Resource and ...
11
votes
1
answer
18k
views
How to generate API Documentation using openapi-generator?
I'm new to the OpenAPI 3.0.0.
I have successfully created a java client library using an openapi-generator.
But OpenAPI Generator allows the generation of API client libraries (SDK generation), ...
11
votes
4
answers
9k
views
Are there any generators that support OpenAPI 3?
At the time of writing this the OpenAPI 3 spec is relatively new. I am struggling to find any documentation generators that support version 3.0.
Does anyone know of generators that support OpenAPI v3....
11
votes
2
answers
10k
views
How do I override the servers -> url (basepath) when generating client using openapi-generator?
I have an OpenAPI specification document (that I do not control) that contains the following snippet:
servers:
- url: http://www.[someservice].com/api
I am using this OpenAPI document to generate ...
11
votes
2
answers
6k
views
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 ...
10
votes
1
answer
8k
views
OpenApi 3.0.2 | Spring Server Generator | Api/Controller interface naming
I am trying to workout a generated server side Spring MVC code for a OpenApi 3.0.2 specification.
This is how one of the `paths' look like :-
paths:
/api/v1/int/integrations/{some-path-variable}/...
10
votes
1
answer
11k
views
How to use generated OpenAPI client inside React?
I have generated my API client with openapi-generator-cli generate -i https://linktomybackendswagger/swagger.json -g typescript-axios -o src/components/api --additional-properties=supportsES6=true
Now ...
10
votes
2
answers
4k
views
Avoid wrapping request object into InlineObject1 in OpenAPI Generator from OpenAPI 3.0 spec to Typescript
I am trying to generate Typescript client with OpenAPI Generator 4.0.0-SNAPSHOT (our manager asked us to use that version for some reason) that reads an OpenAPI 3.0 spec. All of our current endpoints ...
10
votes
4
answers
10k
views
How to generate OpenAPI sources from gradle when building Android app
What I'm trying to achieve
I'm trying to generate my REST API client for Android using OpenAPI Generator from the build.gradle script. That way, I wouldn't have to run the generator command line every ...
10
votes
1
answer
3k
views
JsonIgnore using Open API spec
I use OpenAPI spec to generate Java POJOs. What do I need to specify in Open API yaml to generate the equivalent of below POJO ?
...
@JsonIgnore
public String ignoredProperty;
...
I have the yaml ...
10
votes
1
answer
2k
views
OpenAPI PHP client giving Fatal Error with anyOf
I'm trying to make an OpenAPI autogenerated PHP client using anyOf and allOf properties.
The goal is to be able to return an array with polymorphism in it: objects of different types.
Also those ...
10
votes
2
answers
19k
views
OpenApi: how to describe error codes and messages?
I'd like to provide a series of custom codes and message for my error 400 but can't find any way to do so.
Ideally something like:
Error:
type: object
enum:
- [E01, 'Error1']
- [E02, '...
10
votes
2
answers
10k
views
Why does openapi-generator use imports that do not exist
I am using openapi-codegen version 4.2.2 and openapi specification 3.0.0 to generate a java server API from a yaml file like this:
openapi-generator generate -i test.yaml -g spring -o /tmp/springTest
...
9
votes
2
answers
14k
views
Getting "inject() must be called from an injection context" after upgrading to Angular 11
After upgrading to Angular 11, I am not able to ng serve my web application anymore.
I am generating the client using Spring Doc and the latest OpenAPI generator gradle-plutin (5.0.0).
The problem ...
9
votes
2
answers
32k
views
Cannot deserialize value of type `java.time.OffsetDateTime` from String in openapi client
I have a spring boot application with a java client generated via the gradle plugin:
openApiGenerate {
generatorName = "java"
inputSpec = specsYml
outputDir = "$buildDir/...
9
votes
2
answers
4k
views
Does urllib3 support HTTP/2 Requests? Will it?
I know the following about various python HTTP libraries:
Requests does not support HTTP/2 requests.
Hyper does support HTTP/2 requests, but is archived as of early 2021 and wouldn't be a good choice ...
9
votes
1
answer
8k
views
Prevent openapi-generator renaming enums in JavaScript/TypeScript
We're using the openapi generator to generate our REST client. Works really well, until we started using enums in the UPERCASE_UNDERSCORE format. It strips out the underscore. The main problem with ...
9
votes
1
answer
15k
views
OpenAPI generator add annotation on field level
I am using openapi generator (5.4.0) with gradle(7.3.3) and SpringBoot (2.6.6).
my OpenApi configuration:
ext.openApiConfigOptions = [
library : "spring-boot&...
9
votes
1
answer
8k
views
Is it possible to exclude paths in Openapi code generation?
We are using a large third party API with many optional features. There are 27 endpoints and we need only a few of these from Maven. We are using server side generation.
If you are interested the API ...
9
votes
0
answers
4k
views
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}':
...
9
votes
0
answers
5k
views
Is there a way to get the error response object when using generated webclient API to call a webservice that fails?
I have a REST service that takes an id and two strings as json and returns the id and the two strings concatenated as json. If there errors it can return statuscodes 400, 404 and 500 with a json error ...
8
votes
2
answers
9k
views
How to include the client from openapi-generator in a gradle java application?
I want to create a gradle java application that generates a client from an openAPI specification file and uses that client.
So I created a java application with gradle init (type:application, language:...