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

时间:2019-08-06 13:16:18

标签: html swagger swagger-editor

我正在为一个项目做文档。在网站上,所有内容均在预览中正确显示,尽管显示错误“解析器错误无法读取未定义的属性'0'”。 在html2中生成客户端时,响应架构为空。 更新:现在显示完整代码。

我尝试剪切一个级别(Entity-> EntityItem-> EntityResponse到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'

2 个答案:

答案 0 :(得分:1)

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

operationId: nip?date

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

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

答案 1 :(得分:1)

找到了解决方案,这是由于“ allOf”的滥用,没有它们,错误停止并且HTML正确生成。仅在“人员”中有意义,其他所有情况都被删除。