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.53k stars 6.51k forks source link

Compilation error while compiling client code generated through open api maven plugin #685

Open AnuragGarg89 opened 6 years ago

AnuragGarg89 commented 6 years ago

Description

mvn compile results in build failure because of missing import of the file org.openapitools.client.model.Link;

openapi-generator version

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

OpenAPI declaration file content or url

pom.xml and .yaml used for generating java client code: https://gist.github.com/AnuragGarg89/3118e8ee58f19a9ee87ff775a9265662

Steps to reproduce

create a maven project do mvn generate sources using the pom attached do mvn clean compile expected build success actual compilation error and build failure

jmini commented 6 years ago

I looked at your spec, near Link: you have a strange object: https://gist.github.com/AnuragGarg89/3118e8ee58f19a9ee87ff775a9265662#file-sdp-yaml-L1179-L1182 I am not sure that this is the root of the problem.

To analyze this issue, it would be great if you can reduce the input spec to a minimal example.

AnuragGarg89 commented 6 years ago
swagger: '2.0'
info:
  description: Api Documentation
  version: '1.0'
  title: Api Documentation
  termsOfService: 'urn:tos'
  contact: {}
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0'
host: qa.api.sdp.ihsmvals-dev.com
basePath: /
tags:
  - name: web-mvc-endpoint-handler-mapping
    description: Web Mvc Endpoint Handler Mapping
paths:
  /actuator:
    get:
      tags:
        - web-mvc-endpoint-handler-mapping
      summary: links
      operationId: linksUsingGET
      consumes:
        - application/json
      produces:
        - application/json
        - application/vnd.spring-boot.actuator.v2+json
      responses:
        '200':
          description: OK
          schema:
            type: object
            additionalProperties:
              type: object
              additionalProperties:
                $ref: '#/definitions/Link'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Not Found
definitions:
  Batch:
    type: object
    properties:
      batchId:
        type: string
      snapTime:
        type: string
        format: date-time
      source:
        type: string
      supplier:
        type: string
      startTime:
        type: string
        format: date-time
      exchange:
        type: string
  Link:
    type: object
    properties:
      href:
        type: string
      templated:
        type: boolean
  'Map?string,Link?':
    type: object
    additionalProperties:
      $ref: '#/definitions/Link'

Jérémie Bresson - Does this help?

jmini commented 6 years ago

I have edited your example for better readabillity...

Is really 'Map?string,Link?' really the name of the type that you want? This might be a valid "Swagger V2 Spec", but it looks wired to me.

Can you not rename it LinksMap or something similar?

AnuragGarg89 commented 6 years ago

Map«string,Link» this is what it was in my original json

wing328 commented 6 years ago

Map«string,Link» this is what it was in my original json

"Map«string,Link»" looks like the name of the type. You should replace it with something more meaningful such as "LinkMap"