HTML 中生成的客户端中的 Swagger-Editor 空响应

Swagger-Editor empty response in client generated in HTML

我正在为一个项目做文档。在网站上,所有内容都在预览中正确显示,但显示错误 "Resolver error Cannot read property '0' of undefined"。 在 html2 中生成客户端时,响应架构为空白。 更新: 现在显示完整代码。

我试过切一级(Entity->EntityItem->EntityResponse to Entity->EntityResponse),错误停止,HTML仍然没有显示完整数据。

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'

问题似乎是由操作 ID 中的 ? 问号引起的:

operationId: nip?date

如果删除问号,HTML2 文档将包含响应模式。

您可以在 https://github.com/swagger-api/swagger-codegen/issues 的 Swagger Codegen 存储库中提交错误报告。

找到解决方案,这是由于 "allOf" 的误用,没有它们错误停止并正确生成 HTML。它只在 "Person" 中有意义,所有其他情况都被删除。