Openapi Generator min max range integer Go

PHPz
Release: 2024-02-12 18:27:08
forward
497 people have browsed it

Openapi Generator 最小最大范围整数Go

php editor Apple recommends using Openapi Generator to generate the minimum and maximum range integers in Go language. Openapi Generator is a powerful code generation tool that automatically generates client-side and server-side code according to the OpenAPI specification. In the Go language, the minimum and maximum range of integers are represented by constants in the math package. Using Openapi Generator can easily generate the definition and usage code of these constants, greatly improving development efficiency. If you need to use the minimum and maximum range of integers in Go language development, you might as well try Openapi Generator!

Question content

I have a go project using the openapi generator and openapi: "3.0.3" .

I'm trying to implement error validation using the minimum and maximum ranges of int64 request body variables. I think this type of validation can happen in the generated controller. For example, something like the assertpetrequired example. I looked at the controller-api.mustache file and didn't see anything useful. My post request body looks like this (I've tried every combination I can think of: 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
Copy after login

Is there some additional library that needs to be added, or am I missing something basic in the yaml file?

Workaround

I assume you are generating a go server, not a go client.

Unfortunately, the Go server generator does not yet support validation. But this feature is planned for version 7.0.0, scheduled for June 2023.

The above is the detailed content of Openapi Generator min max range integer Go. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template