apisix-dashboard icon indicating copy to clipboard operation
apisix-dashboard copied to clipboard

import openapi.yaml 无法识别 x-apisix-service_id

Open shuqingzai opened this issue 2 years ago • 3 comments

Issue description

参考: IMPORT_OPENAPI_USER_GUIDE 直接导入 openapi 3.0 ,文件格式: yaml,因为把 x-apisix-service_id 当成是 数字 无法识别,应该是 前端JavaScript 数字长度超出,如果是显式声明为 string 则可以导入

image

以下是文件大概表述

openapi: 3.0.3
info:
  title: 'Demo API'
  description: 'Demo 接口'
  version: 0.0.1
servers:
  - url: '{protocol}://{hostname}'
    description: 服务器信息
    variables:
      protocol:
        enum:
          - http
          - https
        default: http
        description: 通信协议
      hostname:
        enum:
          - 127.0.0.1:8000
          - host.docker.internal:8000
        default: 127.0.0.1:8000
        description: 服务器域名|IP地址
paths:
  /V1/demo/{id}:
    delete:
      tags:
        - Demo
      operationId: Demo_DeleteDemo
      parameters:
        - name: id
          in: path
          description: ID
          required: true
          schema:
            type: integer
            format: fixed64
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteDemoReply'
        default:
          description: Default error response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Status'
      x-apisix-status: 1
      x-apisix-service_id: 418666210796765901
components:
  schemas:
    DeleteDemoReply:
      type: object
      properties: {}
      description: 删除 Demo - 响应体
    GoogleProtobufAny:
      type: object
      properties:
        '@type':
          type: string
          description: The type of the serialized message.
      additionalProperties: true
      description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message.
    Status:
      type: object
      properties:
        code:
          type: integer
          description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
          format: int32
        message:
          type: string
          description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
        details:
          type: array
          items:
            $ref: '#/components/schemas/GoogleProtobufAny'
          description: A list of messages that carry the error details.  There is a common set of message types for APIs to use.
      description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).'
tags:
  - name: Demo

解决方式: 注意: yamlx-apisix-service_id 没有使用 双引号 "" 包裹,会被认为是 number,只需要显示声明为 string 才能被导入 修改前

不可以导入后台

      x-apisix-service_id: 418666210796765901

修改后

可以导入后台

      x-apisix-service_id: "418666210796765901"

Expected behavior

解析 x-apisix-service_id 应该当成 string 处理,或者可以处理 长int

因为 openapi 文档一般都是程序自动生成,不会去修改,现在需要每次生成后手动修改

How to Reproduce

使用上述描述的 yaml 导入即可

Screenshots

No response

Environment

  • apisix version (cmd: apisix version):
apisix version
/usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua version
2.15.0 
  • OS (cmd: uname -a):
uname -a
Linux apisix1 5.10.104-linuxkit #1 SMP Thu Mar 17 17:08:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V):
  • etcd version, if have (cmd: run etcd --version):
  • apisix-dashboard version, if have:
docker 官方镜像: 2.13-centos
  • Browser version, if have:

Additional context

No response

shuqingzai avatar Jul 29 '22 06:07 shuqingzai

您好,请查看新版本的Open API 导入。

zfkube0x1 avatar Aug 01 '22 12:08 zfkube0x1

您好,请查看新版本的Open API 导入。

什么意思?新版本?最新版的不是 v2.13 吗?

shuqingzai avatar Aug 01 '22 13:08 shuqingzai

@shuqingzai 我看最新的代码已经处理了,等他们发布就好了

varSmallRookie avatar Aug 04 '22 16:08 varSmallRookie