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

设置route.Parameters时ParamType报错 #743

Open
rachihoaoi opened this issue Dec 4, 2019 · 5 comments
Open

设置route.Parameters时ParamType报错 #743

rachihoaoi opened this issue Dec 4, 2019 · 5 comments

Comments

@rachihoaoi
Copy link

在试着写demo的时候尝试对route下面的Parameters进行配置以便提供swagger里的数据,碰到个问题是当Parameters.ParamType设置为restful.BodyParameterKind时直接panic,请问有什么解决办法么

func (user *User) Login (b *rf.Context) {
	in := new(TestInput)
	_ = b.ReadEntity(in)
	b.Write([]byte("do"))
}

func (user *User) URLPatterns() []rf.Route {
	return []rf.Route{
		{
			Method: http.MethodPost,
			Path: "/login",
			ResourceFunc: user.Login,
			Parameters: []*rf.Parameters{
				{Name: "test", ParamType: restful.BodyParameterKind, DataType: "object"},
			},
		},
	}
}

报错堆栈
image

@tianxiaoliang
Copy link
Member

Hi,上下文的日志请提供的完整些

@tianxiaoliang
Copy link
Member

Hi,上下文的日志请提供的完整些

不好意思,刚才是图片刷了一半,误会了

@tianxiaoliang
Copy link
Member

实际上ParamType是不支持body的,请使用Read参数
image

https://github.com/apache/servicecomb-kie/blob/master/server/resource/v1/kv_resource.go

另外我们的校验代码没做充分,可否为我们贡献代码,来进行合法校验避免panic为开发者带来困扰和定位困难?

@dengguojie
Copy link
Collaborator

dengguojie commented Jan 3, 2020

It seems ok for me:
image
image
@tianxiaoliang @

@dengguojie
Copy link
Collaborator

it happens when i remove 'Read' parameter ( only BodyParameterKind) ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants