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.81k stars 6.58k forks source link

[BUG] [MARKDOWN] Generated Links from nested objects not match with generated Folders #4997

Open alexander-matthiesen opened 4 years ago

alexander-matthiesen commented 4 years ago

Description

If an OpenAPI-Specificationhas nested objects for example responses or other objects, the generated model-folder isn't reachable via a link in the model.mustache field.

openapi-generator version

Markdown-Generator version 4.2.3-SNAPSHOT

Suggest a fix

Not generation the module name like "object_nested1_nested2" instead use ObjectNested1Nested2 that it matches the generated folder.

wing328 commented 4 years ago

Can you provide a spec so that we can more easily repeat the issue?

alexander-matthiesen commented 4 years ago

Here you go, the Problem is with the nested Objects for example "Owner" in "TestCard".

swagger: '2.0'
info:
  title: TestAPI
  version: '1.0'
  termsOfService: 'https://tesst.com'
  contact:
    name: Test GmbH
    url: 'https://test.com'
    email: api@test.com
  license:
    name: Copyright
    url: 'https://test.com'
  description: Definition of the Test API.
host: api.test.ag
paths:
  /cards:
    get:
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/ListTestCards'
          examples:
            application/vnd.api+json:
              data:
                - type: testCard
                  id: minim tempor laboris officia sit
                  attributes:
                    maskedPan: occaecat consequat
                    network: testcard
                    engravedLine1: dolor nisi fugiat
                    engravedLine2: aliquip
                    activationDate: nisi
                    expiryDate: ipsum nulla est fugiat exercitation
                    balance:
                      date: '2019-03-01'
                      currencyCode: EUR
                      value: '520.00'
                    state: blocked
                    owner:
                      firstName: magna reprehenderit est dolore do
                      lastName: ex id sunt
                      title: et officia Lorem
                      salutation: laborum non ut
              pagination:
                page: 94756258.36559254
              meta: eu sit
        '403':
          description: ''
          schema:
            $ref: '#/definitions/ErrorWrapper'
          examples:
            application/json:
              errors:
                - code: oauth-error
                  title: unauthorized
                  status: '401'
                  detail: Full authentication is required to access this resource
      summary: Index of the testcard.
      operationId: getCards
      tags:
        - cards
      description: Returns all cards belonging to the logged in customer
      x-auth-type: Application & Application User
      x-throttling-tier: Unlimited
schemes:
  - https
consumes:
  - application/vnd.api+json
produces:
  - application/vnd.api+json
definitions:
  TestCard:
    type: object
    title: TestCard
    properties:
      type:
        type: string
        example: testCard
      id:
        type: string
        example: 2d2177d0-af2a-4033-b156-3b2274e39870
      attributes:
        type: object
        required:
          - type
          - id
          - attributes
        properties:
          type:
            type: string
          id:
            type: string
            description: |-
              Unique test card token.
              It is generated by the test service.
            example: c8f0419e-0969-4d82-a642-b52f9698c25c
          attributes:
            type: object
            required:
              - owner
            properties:
              owner:
                type: object
                description: Name of the Owner of the card.
                required:
                  - firstName
                  - lastName
                  - title
                properties:
                  firstName:
                    type: string
                    example: Maxim Peters
                  lastName:
                    type: string
                    example: Mayer
                  title:
                    type: string
                    example: Dr.
                  salutation:
                    type: string
                    description: Test
                    example: test
  ListTestCards:
    type: object
    title: List of Test Cards
    properties:
      data:
        type: array
        items:
          $ref: '#/definitions/TestCard'
  ErrorWrapper:
    type: object
    title: 'JSON:API Error Wrapper'
    description: Wraps multiple errors into one response
    properties:
      errors:
        $ref: '#/definitions/Error'
  Error:
    type: object
    title: Error Response JSON API
    description: This is the default Error object that will be returned to users when a problem (exception) occured during the request processing.
    properties:
      errors:
        type: object
        description: represents a JSON API spec error.
        properties:
          code:
            type: string
            description: A machine-readable error code within the message
          title:
            type: string
            description: A short summary of the problem.
          detail:
            type: string
            description: A human-readable error description.
          status:
            type: string
            description: The HTTP status code represented as a numerical string.
securityDefinitions: {}
tags:
  - name: cards
parameters: {}
alexander-matthiesen commented 4 years ago

The Error occurs when using the attached mustache-templates.

templates.zip