Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

只有get请求才获取params #39

Closed
snoopy1412 opened this issue Jul 3, 2020 · 5 comments
Closed

只有get请求才获取params #39

snoopy1412 opened this issue Jul 3, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@snoopy1412
Copy link

snoopy1412 commented Jul 3, 2020

我尝试了用idea 导出文档后,有两种格式的请求

1. post请求

接口路径:POST/supply/attachment-create

他的请求参数如下
image

2. get请求

GET/supply/attachment-list

他的请求参数如下
image

但是在生成的types文件中,post请求并未包含参数

/**
 * @请求头 `DELETE /supply/attachment-list`
 * @更新时间 `2020-07-03 09:15:15`
 */
export interface DeleteAttachmentListRequest {}

而get请求
对dataId,tableType,taskId 进行了限定(其实还有点好奇,这三个熟悉的string类型是如何获取的);

/**
 * @请求头 `GET /supply/attachment-list`
 * @更新时间 `2020-07-03 09:15:14`
 */
export interface GetAttachmentListRequest {
  dataId: string
  tableType: string
  taskId?: string
}

猜测可能是因为Headers不一样,导致post请求无法获取具体参数,但是不知道如何在配置文件中做具体的适配


图片可能要翻墙才能看到?其实就是POST请求参数多了个headers的显示,Content-Type : multipart/form-data, Query部分正常显示参数及说明,而get请求没有headers部分。

@fjc0k
Copy link
Owner

fjc0k commented Jul 3, 2020

#34 同样的问题。

@fjc0k fjc0k added the enhancement New feature or request label Jul 3, 2020
@fjc0k
Copy link
Owner

fjc0k commented Jul 3, 2020

至于为啥 query 字段的类型定义全是 string,因为本质上 query 就是 string:http:https://foo.bar?id=1id=1 中的 1 实质是一个数值字符串,YApi 也不支持设置 query 字段的类型,因此,默认为 string 比较符合实际情况。

@snoopy1412
Copy link
Author

snoopy1412 commented Jul 3, 2020

#34 同样的问题。

如果是自家实现的接口,最好要么全部 get,要么全部 post。这是说,我需要把接口都换成get请求方式嘛?
但是如果是我理解的意思,好像和业务思路不太一致,整个业务包含了get,post,delete,put四种请求方式,不知道程序里面支不支持不同环境下的params的获取?

@fjc0k
Copy link
Owner

fjc0k commented Jul 3, 2020

就是说你让后端把参数全部放进 query params 或者 form data。

@snoopy1412
Copy link
Author

就是说你让后端把参数全部放进 query params 或者 form data。

好的,谢谢

@fjc0k fjc0k mentioned this issue Jul 10, 2020
@fjc0k fjc0k closed this as completed in ac43e58 Aug 5, 2020
@fjc0k fjc0k reopened this Dec 20, 2020
@fjc0k fjc0k closed this as completed in 4057796 Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants