OpenAPITools / OpenAPITools/openapi-generator

openapi-generator-maven-plugin syntax errors for range codes, e.g. 4XX

Open
#9,046 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

We use the following dependencies:

For annotations

		<dependency>
		<groupId>io.swagger.parser.v3</groupId>
		<artifactId>swagger-parser</artifactId>
		<version>2.0.24</version>
		</dependency>

For generation:

	<plugin>
		<groupId>org.openapitools</groupId>
		<artifactId>openapi-generator-maven-plugin</artifactId>
		<version>5.1.0</version>
		<executions>
...
	</plugin>

We use a range definition (4XX) as to OpenAPI v3 specification for response codes, this generates the following code, which has a syntax error in it:

image

openapi-generator version

5.1.0

OpenAPI declaration file content or url

If you post the code inline, please wrap it with

...
      responses:
        "4XX":
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
...
Command line used for generation

using the openapi maven generator plugin:
java

Steps to reproduce

generate with a range response code

Related issues/PRs

Somehow this should have been solved with https://github.com/OpenAPITools/openapi-generator/pull/7854 , although I do not understand how & it does not seem to work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the OpenAPI response definition using the "4XX" range and the Java generator entry point invoked by openapi-generator-maven-plugin. Review the related PR 7854 and reproduce generation with the supplied declaration; done means the generated Java output is syntactically valid for range response codes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.