OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.48k stars 6.5k forks source link

Hateoas option generate Links even for request or ErrorResponse #18464

Open leccyril opened 5 months ago

leccyril commented 5 months ago

Bug Report Checklist

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 image

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<?>

repo : https://github.com/leccyril/openapi-generator

leccyril commented 5 months ago

any idea?

leccyril commented 4 months ago

@canadaduane any idea ?

altrof commented 3 months ago

any solutions?