shuqingzai opened a new issue, #2554:
URL: https://github.com/apache/apisix-dashboard/issues/2554

   ### Issue description
   
   参考: 
[IMPORT_OPENAPI_USER_GUIDE](https://apisix.apache.org/zh/docs/dashboard/IMPORT_OPENAPI_USER_GUIDE)
 直接导入 `openapi 3.0` ,文件格式: `yaml`,因为把 `x-apisix-service_id` 当成是 数字 无法识别,应该是 
前端JavaScript 数字长度超出,如果是显式声明为 `string` 则可以导入
   
   
![image](https://user-images.githubusercontent.com/44406033/181693792-b3d97fc9-1c1a-462f-a377-cd9599f5c0bf.png)
   
   以下是文件大概表述
   ```yaml
   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
   
   ```
   
   
   解决方式:
   注意: `yaml` 中 `x-apisix-service_id` 没有使用 `双引号 ""` 包裹,会被认为是 `number`,只需要显示声明为 
`string` 才能被导入
   修改前
   > 不可以导入后台
   ```yaml
         x-apisix-service_id: 418666210796765901
   ```
   修改后
   > 可以导入后台
   ```yaml
         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`): 
   ```shell
   apisix version
   /usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua version
   2.15.0 
   ```
   - OS (cmd: `uname -a`): 
   ```shell
   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: 
   ```shell
   docker 官方镜像: 2.13-centos
   ```
   - Browser version, if have:
   
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to