-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Labels
Description
Is your feature request related to a problem? Please describe.
for a spec with value validation (maxLength, maximum, required...)
openapi: 3.0.3
info:
version: 1.0.0
title: Example
servers:
- url: http://localhost:8080
paths:
/data:
get:
responses:
200:
description: example response
content:
application/json:
schema:
type: object
required: [id]
properties:
id:
type: string
maxLength: 10
generate go client by v5.4.0 generate -i openapi.yml -g go
and write code
package main
import (
"context"
"fmt"
openapi "github.com/GIT_USER_ID/GIT_REPO_ID"
"net/http"
)
func main() {
go http.ListenAndServe("127.0.0.1:8080", http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
writer.Header().Add("Content-Type", "application/json; charset=utf8")
writer.Write([]byte("{}"))
}))
data, _, err := openapi.NewAPIClient(openapi.NewConfiguration()).DefaultApi.DataGet(context.Background()).Execute()
fmt.Println(data, err)
}will output
&{} <nil>
neither client side nor server side validate parameter.
Describe the solution you'd like
import some third library to validate data with schema.
or generate validate code with template
Describe alternatives you've considered
Additional context
Reactions are currently unavailable