openapi: generate

This commit is contained in:
Quaternions 2024-12-17 20:50:25 -08:00
parent 6545fa703d
commit 1d3e553390
3 changed files with 30 additions and 30 deletions

View File

@ -624,18 +624,18 @@ func (s *Pagination) Encode(e *jx.Encoder) {
// encodeFields encodes fields. // encodeFields encodes fields.
func (s *Pagination) encodeFields(e *jx.Encoder) { func (s *Pagination) encodeFields(e *jx.Encoder) {
{ {
e.FieldStart("Page") e.FieldStart("Number")
e.Int32(s.Page) e.Int32(s.Number)
} }
{ {
e.FieldStart("Limit") e.FieldStart("Size")
e.Int32(s.Limit) e.Int32(s.Size)
} }
} }
var jsonFieldsNameOfPagination = [2]string{ var jsonFieldsNameOfPagination = [2]string{
0: "Page", 0: "Number",
1: "Limit", 1: "Size",
} }
// Decode decodes Pagination from json. // Decode decodes Pagination from json.
@ -647,29 +647,29 @@ func (s *Pagination) Decode(d *jx.Decoder) error {
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) { switch string(k) {
case "Page": case "Number":
requiredBitSet[0] |= 1 << 0 requiredBitSet[0] |= 1 << 0
if err := func() error { if err := func() error {
v, err := d.Int32() v, err := d.Int32()
s.Page = int32(v) s.Number = int32(v)
if err != nil { if err != nil {
return err return err
} }
return nil return nil
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"Page\"") return errors.Wrap(err, "decode field \"Number\"")
} }
case "Limit": case "Size":
requiredBitSet[0] |= 1 << 1 requiredBitSet[0] |= 1 << 1
if err := func() error { if err := func() error {
v, err := d.Int32() v, err := d.Int32()
s.Limit = int32(v) s.Size = int32(v)
if err != nil { if err != nil {
return err return err
} }
return nil return nil
}(); err != nil { }(); err != nil {
return errors.Wrap(err, "decode field \"Limit\"") return errors.Wrap(err, "decode field \"Size\"")
} }
default: default:
return d.Skip() return d.Skip()

View File

@ -398,28 +398,28 @@ func (o OptSubmissionFilter) Or(d SubmissionFilter) SubmissionFilter {
// Ref: #/components/schemas/Pagination // Ref: #/components/schemas/Pagination
type Pagination struct { type Pagination struct {
Page int32 `json:"Page"` Number int32 `json:"Number"`
Limit int32 `json:"Limit"` Size int32 `json:"Size"`
} }
// GetPage returns the value of Page. // GetNumber returns the value of Number.
func (s *Pagination) GetPage() int32 { func (s *Pagination) GetNumber() int32 {
return s.Page return s.Number
} }
// GetLimit returns the value of Limit. // GetSize returns the value of Size.
func (s *Pagination) GetLimit() int32 { func (s *Pagination) GetSize() int32 {
return s.Limit return s.Size
} }
// SetPage sets the value of Page. // SetNumber sets the value of Number.
func (s *Pagination) SetPage(val int32) { func (s *Pagination) SetNumber(val int32) {
s.Page = val s.Number = val
} }
// SetLimit sets the value of Limit. // SetSize sets the value of Size.
func (s *Pagination) SetLimit(val int32) { func (s *Pagination) SetSize(val int32) {
s.Limit = val s.Size = val
} }
// Ref: #/components/schemas/Script // Ref: #/components/schemas/Script

View File

@ -106,13 +106,13 @@ func (s *Pagination) Validate() error {
MaxExclusive: false, MaxExclusive: false,
MultipleOfSet: false, MultipleOfSet: false,
MultipleOf: 0, MultipleOf: 0,
}).Validate(int64(s.Page)); err != nil { }).Validate(int64(s.Number)); err != nil {
return errors.Wrap(err, "int") return errors.Wrap(err, "int")
} }
return nil return nil
}(); err != nil { }(); err != nil {
failures = append(failures, validate.FieldError{ failures = append(failures, validate.FieldError{
Name: "Page", Name: "Number",
Error: err, Error: err,
}) })
} }
@ -126,13 +126,13 @@ func (s *Pagination) Validate() error {
MaxExclusive: false, MaxExclusive: false,
MultipleOfSet: false, MultipleOfSet: false,
MultipleOf: 0, MultipleOf: 0,
}).Validate(int64(s.Limit)); err != nil { }).Validate(int64(s.Size)); err != nil {
return errors.Wrap(err, "int") return errors.Wrap(err, "int")
} }
return nil return nil
}(); err != nil { }(); err != nil {
failures = append(failures, validate.FieldError{ failures = append(failures, validate.FieldError{
Name: "Limit", Name: "Size",
Error: err, Error: err,
}) })
} }