英文:
Openapi Generator Minimum Maximum Range integer Go
问题
我有一个使用OpenAPI Generator和openapi: "3.0.3"
的Go项目。
我正在尝试使用minimum
和maximum
范围来实现对int64请求体变量的错误验证。我认为这种类型的验证可以在生成的控制器中进行。例如,类似于AssertPetRequired示例中的某个位置。我查看了controller-api.mustache文件,但没有找到有用的内容。我的POST请求体如下所示(我尝试了关于minimum、maximum、exclusiveMinimum和exclusiveMaximum的所有组合)。
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
id:
type: string
amount:
type: integer
format: int64
minimum: 1
exclusiveMinimum: true
maximum: 10
exclusiveMaximum: true
label:
type: string
required:
- id
- amount
我是否需要添加其他库,或者我在我的yaml
文件中漏掉了一些基本内容?
英文:
I have a go project using the OpenAPI Generator with openapi: "3.0.3"
.
I am attempting to implement error validation using a minimum
and maximum
range for an int64 request body variable. I would think that this type of validation could happen within the generated controllers. For example, somewhere like the AssertPetRequired example. I looked through the controller-api.mustache file and do not see anything helpful. My post request body looks like the following (I’ve tried every combination I can think of for: minimum, maximum, exclusiveMinimum and exclusiveMaximum.
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
id:
type: string
amount:
type: integer
format: int64
minimum: 1
exclusiveMinimum: true
maximum: 10
exclusiveMaximum: true
label:
type: string
required:
- id
- amount
Is there some additional library that I need to add or am I missing something basic within my yaml
file?
答案1
得分: 1
不幸的是,Go服务器生成器目前还不支持验证功能。但是这个功能已经计划在7.0.0版本中实现,该版本计划于2023年6月发布。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论