Search code examples
htmlswaggerswagger-editor

Swagger-Editor empty response in client generated in HTML


I'm doing documentation for a project. On the website everything is showing correctly in the preview, though it is showing error "Resolver error Cannot read property '0' of undefined". When generating client in html2 response schema is blank. UPDATE: showing full code now.

I've tried cutting one level (Entity->EntityItem->EntityResponse to Entity->EntityResponse), error stopped, HTML still not showing full data.

openapi: 3.0.0
info:
  description: not working
  version: "1.0.0"
  title: ...
  contact:
    email: work@pls.com
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'

#====================================================================================
paths:
  /search/nip/{nip}:
    get:
      operationId: nip?date

      parameters:
        - in: path
          name: nip
          required: true
          schema:
            type: string
            minLength: 10
            maxLength: 10
          description: "Nip"
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'

      responses:
        '200':
          description: ...
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityResponse'

        '400':
          description: ...

      description: ...


  /search/regon/{regon}:
    get:
      operationId: regon?date

      parameters:
        - in: path
          name: regon
          required: true
          schema:
            type: string
            pattern: '^\d{9}$|^\d{14}$'
            description: ...
            example: '364760520'
          description: Regon
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'

      responses:
        '200':
          description: ...
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityResponse'

        '400':
          description: ...
      description: ...


  /search/bank-account/{bank-account}:
    get:
      operationId: bank-account?date

      parameters:
        - in: path
          name: bank-account
          required: true
          schema:
            type: string
            minLength: 26
            maxLength: 26
          description: ...
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'

      responses:
        '200':
          description: ...
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityListResponse'

        '400':
          description: ...

      description: ...

  /check/nip/{nip}/bank-account/{bank-account}:
    get:
      operationId: checkNip

      parameters:
        - in: path
          name: nip
          required: true
          schema:
            type: string
            minLength: 10
            maxLength: 10
          description: "Nip"
        - in: path
          name: bank-account
          required: true
          schema:
            type: string
            minLength: 26
            maxLength: 26
          description: Numer rachunku bankowego
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'

      responses:
        '200':
          description: ...
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityCheckResponse'

        '400':
          description: ...

      description: ...

  /check/regon/{regon}/bank-account/{bank-account}:
    get:
      operationId: checkRegon

      parameters:
        - in: path
          name: regon
          required: true
          schema:
            type: string
            pattern: '^\d{9}$|^\d{14}$'
            description: numer identyfikacyjny REGON
            example: '364760520'
          description: Regon
        - in: path
          name: bank-account
          required: true
          schema:
            type: string
            minLength: 26
            maxLength: 26
          description: ...
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'

      responses:
        '200':
          description: ...
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityCheckResponse'

        '400':
          description: ...

      description: ...

      #====================================================================================

components:
  schemas:
    EntityRequestBase:
      properties:
        data:
          type: string
          format: date
          example: '2019-05-17'
        bank-account:
          type: array
          items:
            type: string
            minLength: 26
            maxLength: 26
            example: '90249000050247256316596736'
        nip:
          type: string
          minLength: 10
          maxLength: 10
          example: '1111111111'
        regon:
          type: string
          pattern: '^\d{9}$|^\d{14}$'
          description: |
            ...
          example: '364760520'
        pesel:
          type: string
          description: |
            ...
          minLength: 11
          maxLength: 11
          example: '22222222222'
      required:
        - data


    #====================================================================================
    Exception:
      properties:
        message:
          type: string
          example: 'error message'
        code:
          type: integer
      required:
        - message
        - code

    #====================================================================================
    Person:
      properties:
        firstName:
          type: string
          example: Jan
        lastName:
          type: string
          example: Nowak
        pesel:
          $ref: '#/components/schemas/EntityRequestBase/properties/pesel'
        nip:
          type: string
          minLength: 10
          maxLength: 10
          example: '1111111111'
    #====================================================================================
    EntityPerson:
      allOf:
        - $ref: '#/components/schemas/Person'
        - properties:
            companyName:
              type: string
              example: 'Nazwa firmy'
    #====================================================================================
    EntityCheck:
      properties:
        accountAssigned:
          type: string
          example: TAK
          description: |
            ...
        requestId:
          type: string
          example: 'd2n10-84df1a1'
    #====================================================================================
    Entity:
      allOf:

        - properties:
            name:
              type: string
              example: 'ABC Jan Nowak'
              description: |
                ...
            nip:
              type: string
              minLength: 10
              maxLength: 10
              example: '1111111111'
            statusVat:
              type: string
              enum:
                - C
                - Z
                - P
              example: Z
              description: |
                ...

            regon:
              type: string
              pattern: '^\d{9}$|^\d{14}$'
              description: |
                ...
              example: '364760520'
            pesel:
              $ref: '#/components/schemas/EntityRequestBase/properties/pesel'
            krs:
              type: string
              example: '0000636771'
              maxLength: 10
              minLength: 10
              description: |
                ...
            residenceAddress:
              type: string
              example: 'ul/ Taka a Owaka 12 01- Warszawa'
              description: |
                ...
            workingAddress:
              type: string
            representatives:
              type: array
              items:
                $ref: '#/components/schemas/Person'
              description: |
                ...
            authorizedClerks:
              type: array
              items:
                $ref: '#/components/schemas/Person'
              description: |
                ...
            partners:
              type: array
              items:
                $ref: '#/components/schemas/EntityPerson'
              description: |
               ...

            registrationLegalDate:
              type: string
              format: date
              example: '2018-02-21'

            registrationDenialDate:
              type: string
              format: date
              example: '2019-02-21'
              description: |
               ...
            registrationDenialBasis:
              type: string
              example: 'Ustawa o podatku od towarów i usług art. 96'
              description: |
                ...
            restorationDate:
              type: string
              format: date
              example: '2019-02-21'
              description: |
               ...
            restorationBasis:
              type: string
              example: 'Ustawa o podatku od towarów i usług art. 96'
              description: |
                ...
            accountNumbers:
              type: array
              items:
                type: string
                minLength: 26
                maxLength: 26
                example: '90249000050247256316596736'
            hasVirtualAccounts:
              type: boolean
              example: true
              description: |
                ...

          required:
            - name
    #====================================================================================
    EntityItem:
      allOf:
        - properties:
            subject:
              $ref: '#/components/schemas/Entity'
            requestId:
              type: string
              example: 'd2n10-84df1a1'
    #====================================================================================
    EntityList:
      allOf:
        - properties:
            subjects:
              type: array
              items:
                $ref: '#/components/schemas/Entity'
              description: |
               ...
            requestId:
              type: string
              example: 'd2n10-84df1a1'
    #====================================================================================
    EntityResponse:
      allOf:
        - properties:
            exception:
              $ref: '#/components/schemas/Exception'
            result:
              $ref: '#/components/schemas/EntityItem'

    EntityCheckResponse:
      allOf:
        - properties:
            exception:
              $ref: '#/components/schemas/Exception'
            result:
              $ref: '#/components/schemas/EntityCheck'

    EntityListResponse:
      allOf:
        - properties:
            exception:
              $ref: '#/components/schemas/Exception'
            result:
              $ref: '#/components/schemas/EntityList'

Solution

  • Found the solution, it was due to the misuse of "allOf", without them error stops and HTML is generated correctly. It only made sense in "Person", all the other cases were deleted.