OpenAPITools / OpenAPITools/openapi-generator
Hateoas option generate Links even for request or ErrorResponse
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- [yesy ] Have you provided a full/minimal spec to reproduce the issue?
- [ yes] Have you validated the input using an OpenAPI validator (example)?
- [ yes] Have you tested with the latest master to confirm the issue still exists?
- [ yes] Have you searched for related issues/PRs?
- What's the actual output vs expected output?
display links for error or input request
Expected: to not display links object and not inherit for error or input request.
Description
We are using HATEOAS with openapi generator for Springboot3 java 21, the issue is all object defined in the swagger.yaml are implementing the Link, problem, for Request or ErrorResponse we don,t want it, at least we don't want to write it on the documentation api
openapi-generator version
7.4.0
OpenAPI declaration file content or url
<configuration>
<inputSpec>${project.basedir}/swagger.yaml</inputSpec>
<generatorName>spring</generatorName>
<library>spring-boot</library>
<apiPackage>com.openapi.generated</apiPackage>
<modelPackage>com.openapi.generated</modelPackage>
<supportingFilesToGenerate>false</supportingFilesToGenerate>
<configOptions>
<disallowAdditionalPropertiesIfNotPresent>false</disallowAdditionalPropertiesIfNotPresent>
<additionalModelTypeAnnotations>@lombok.Builder @lombok.AllArgsConstructor @lombok.EqualsAndHashCode(callSuper = true)
@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY)
</additionalModelTypeAnnotations>
<hateoas>true</hateoas>
<reactive>true</reactive>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
<useSpringBoot3>true</useSpringBoot3>
<useJakartaEe>true</useJakartaEe>
</configOptions>
</configuration>
openapi: '3.1.0'
info:
version: 1.0.0
title: open api generator
termsOfService: http://swagger.io/terms/
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
contact:
name: Support
email: noreply@test.com
servers:
- url: http://localhost:8081
description: local
paths:
/test:
post:
tags:
- test
summary: Create test
description: Create test
operationId: createTest
requestBody:
description: test object
content:
application/json:
schema:
$ref: '#/components/schemas/TestRequest'
required: true
responses:
'201':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestResponse'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/test/{id}:
get:
tags:
- "test"
summary: "get object"
description: "Returns object"
operationId: "getObject"
parameters:
- name: id
in: path
description: Gateway token generated in the network tokenization process
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestResponse'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Token not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
TestResponse:
type: object
properties:
id:
type: string
value:
type: string
TestRequest:
type: object
properties:
number:
type: string
description: The card number ex:1234 1234 1234 1243
ErrorResponse:
type: object
properties:
status:
type: integer
format: int32
description: Request status
type:
type: string
description: Error type
code:
type: string
description: Error code
errors:
type: array
items:
type: string
description: List of error messages
Generation Details
Steps to reproduce
Compile project, then launch it and connect on http://localhost:8082/swagger.html
Suggest a fix
Add parameter in the Object definition in yaml to specify if we want or not extends RepresentationModel<?>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the Spring generator with the supplied Maven configuration and swagger.yaml, then inspect the generated TestRequest, ErrorResponse, and TestResponse models with HATEOAS enabled. Done means request and error models no longer generate or inherit the links object while the expected response behavior remains clear in the generated API documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100