首页 > 解决方案 > JHipster OpenApi 总是返回 501

问题描述

我在 api.yml 上注册的每个服务都有一个 501。我正在使用 JHipster 7.3.0、Open API 3.0.1、Java 11 和 Vue 2.6.14,一切都配置了 JHipster 默认设置。我正在尝试创建 Petstore 示例,我复制了 api.yml,生成代码并实现了一些服务。

奇怪的是,当我尝试从前端应用程序使用服务时,它返回 501,但如果我在 api.yml 中注释定义,它工作正常。

...
/pet/findByTags:
    get:
      tags:
        - pet
      summary: Finds Pets by tags
      description: >-
        Multiple tags can be provided with comma separated strings. Use tag1,
        tag2, tag3 for testing.
      operationId: findPetsByTags
      parameters:
        - name: tags
          in: query
          description: Tags to filter by
          required: false
          explode: true
          schema:
            type: array
            items:
              type: string
      responses:
        '200':
          description: successful operation
          content:
            application/xml:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Pet'
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Pet'
        '400':
          description: Invalid tag value
      security:
        - petstore_auth:
            - 'write:pets'
            - 'read:pets'
...

另一件事是,在某种情况下,服务总是返回 501,但如果我从邮递员那里使用它,它就可以正常工作。

/categories:
    get:
      tags:
        - pet
        - category
      summary: Get all the categories
      description: >-
        Get All the Categories.
      operationId: getCategories
      responses:
        '200':
          description: Category List
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Category'
      security:
        - petstore_auth:
            - 'write:pets'
            - 'read:pets'

标签: jhipsteropenapi

解决方案


推荐阅读