openapi: generate

This commit is contained in:
Quaternions 2025-04-01 14:27:19 -07:00
parent b6ae600a93
commit de8f869b5b
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131
7 changed files with 561 additions and 35 deletions

@ -3682,6 +3682,57 @@ func (c *Client) sendListMapfixes(ctx context.Context, params ListMapfixesParams
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "DisplayName" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "DisplayName",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.DisplayName.Get(); ok {
return e.EncodeValue(conv.StringToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "Creator" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "Creator",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.Creator.Get(); ok {
return e.EncodeValue(conv.StringToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "GameID" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "GameID",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.GameID.Get(); ok {
return e.EncodeValue(conv.Int32ToString(val))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "Sort" parameter.
cfg := uri.QueryParameterEncodingConfig{

@ -5408,6 +5408,18 @@ func (s *Server) handleListMapfixesRequest(args [0]string, argsEscaped bool, w h
Name: "Limit",
In: "query",
}: params.Limit,
{
Name: "DisplayName",
In: "query",
}: params.DisplayName,
{
Name: "Creator",
In: "query",
}: params.Creator,
{
Name: "GameID",
In: "query",
}: params.GameID,
{
Name: "Sort",
In: "query",

@ -235,6 +235,18 @@ func (s *Mapfix) encodeFields(e *jx.Encoder) {
e.FieldStart("ID")
e.Int64(s.ID)
}
{
e.FieldStart("DisplayName")
e.Str(s.DisplayName)
}
{
e.FieldStart("Creator")
e.Str(s.Creator)
}
{
e.FieldStart("GameID")
e.Int32(s.GameID)
}
{
e.FieldStart("CreatedAt")
e.Int64(s.CreatedAt)
@ -273,17 +285,20 @@ func (s *Mapfix) encodeFields(e *jx.Encoder) {
}
}
var jsonFieldsNameOfMapfix = [10]string{
0: "ID",
1: "CreatedAt",
2: "UpdatedAt",
3: "Submitter",
4: "AssetID",
5: "AssetVersion",
6: "Completed",
7: "TargetAssetID",
8: "StatusID",
9: "StatusMessage",
var jsonFieldsNameOfMapfix = [13]string{
0: "ID",
1: "DisplayName",
2: "Creator",
3: "GameID",
4: "CreatedAt",
5: "UpdatedAt",
6: "Submitter",
7: "AssetID",
8: "AssetVersion",
9: "Completed",
10: "TargetAssetID",
11: "StatusID",
12: "StatusMessage",
}
// Decode decodes Mapfix from json.
@ -307,8 +322,44 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"ID\"")
}
case "CreatedAt":
case "DisplayName":
requiredBitSet[0] |= 1 << 1
if err := func() error {
v, err := d.Str()
s.DisplayName = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"DisplayName\"")
}
case "Creator":
requiredBitSet[0] |= 1 << 2
if err := func() error {
v, err := d.Str()
s.Creator = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Creator\"")
}
case "GameID":
requiredBitSet[0] |= 1 << 3
if err := func() error {
v, err := d.Int32()
s.GameID = int32(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"GameID\"")
}
case "CreatedAt":
requiredBitSet[0] |= 1 << 4
if err := func() error {
v, err := d.Int64()
s.CreatedAt = int64(v)
@ -320,7 +371,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"CreatedAt\"")
}
case "UpdatedAt":
requiredBitSet[0] |= 1 << 2
requiredBitSet[0] |= 1 << 5
if err := func() error {
v, err := d.Int64()
s.UpdatedAt = int64(v)
@ -332,7 +383,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"UpdatedAt\"")
}
case "Submitter":
requiredBitSet[0] |= 1 << 3
requiredBitSet[0] |= 1 << 6
if err := func() error {
v, err := d.Int64()
s.Submitter = int64(v)
@ -344,7 +395,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"Submitter\"")
}
case "AssetID":
requiredBitSet[0] |= 1 << 4
requiredBitSet[0] |= 1 << 7
if err := func() error {
v, err := d.Int64()
s.AssetID = int64(v)
@ -356,7 +407,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"AssetID\"")
}
case "AssetVersion":
requiredBitSet[0] |= 1 << 5
requiredBitSet[1] |= 1 << 0
if err := func() error {
v, err := d.Int64()
s.AssetVersion = int64(v)
@ -368,7 +419,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"AssetVersion\"")
}
case "Completed":
requiredBitSet[0] |= 1 << 6
requiredBitSet[1] |= 1 << 1
if err := func() error {
v, err := d.Bool()
s.Completed = bool(v)
@ -380,7 +431,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"Completed\"")
}
case "TargetAssetID":
requiredBitSet[0] |= 1 << 7
requiredBitSet[1] |= 1 << 2
if err := func() error {
v, err := d.Int64()
s.TargetAssetID = int64(v)
@ -392,7 +443,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"TargetAssetID\"")
}
case "StatusID":
requiredBitSet[1] |= 1 << 0
requiredBitSet[1] |= 1 << 3
if err := func() error {
v, err := d.Int32()
s.StatusID = int32(v)
@ -404,7 +455,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"StatusID\"")
}
case "StatusMessage":
requiredBitSet[1] |= 1 << 1
requiredBitSet[1] |= 1 << 4
if err := func() error {
v, err := d.Str()
s.StatusMessage = string(v)
@ -426,7 +477,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
var failures []validate.FieldError
for i, mask := range [2]uint8{
0b11111111,
0b00000011,
0b00011111,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.
@ -481,6 +532,18 @@ func (s *MapfixCreate) Encode(e *jx.Encoder) {
// encodeFields encodes fields.
func (s *MapfixCreate) encodeFields(e *jx.Encoder) {
{
e.FieldStart("DisplayName")
e.Str(s.DisplayName)
}
{
e.FieldStart("Creator")
e.Str(s.Creator)
}
{
e.FieldStart("GameID")
e.Int32(s.GameID)
}
{
e.FieldStart("AssetID")
e.Int64(s.AssetID)
@ -495,10 +558,13 @@ func (s *MapfixCreate) encodeFields(e *jx.Encoder) {
}
}
var jsonFieldsNameOfMapfixCreate = [3]string{
0: "AssetID",
1: "AssetVersion",
2: "TargetAssetID",
var jsonFieldsNameOfMapfixCreate = [6]string{
0: "DisplayName",
1: "Creator",
2: "GameID",
3: "AssetID",
4: "AssetVersion",
5: "TargetAssetID",
}
// Decode decodes MapfixCreate from json.
@ -510,8 +576,44 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) {
case "AssetID":
case "DisplayName":
requiredBitSet[0] |= 1 << 0
if err := func() error {
v, err := d.Str()
s.DisplayName = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"DisplayName\"")
}
case "Creator":
requiredBitSet[0] |= 1 << 1
if err := func() error {
v, err := d.Str()
s.Creator = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Creator\"")
}
case "GameID":
requiredBitSet[0] |= 1 << 2
if err := func() error {
v, err := d.Int32()
s.GameID = int32(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"GameID\"")
}
case "AssetID":
requiredBitSet[0] |= 1 << 3
if err := func() error {
v, err := d.Int64()
s.AssetID = int64(v)
@ -523,7 +625,7 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"AssetID\"")
}
case "AssetVersion":
requiredBitSet[0] |= 1 << 1
requiredBitSet[0] |= 1 << 4
if err := func() error {
v, err := d.Int64()
s.AssetVersion = int64(v)
@ -535,7 +637,7 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
return errors.Wrap(err, "decode field \"AssetVersion\"")
}
case "TargetAssetID":
requiredBitSet[0] |= 1 << 2
requiredBitSet[0] |= 1 << 5
if err := func() error {
v, err := d.Int64()
s.TargetAssetID = int64(v)
@ -556,7 +658,7 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
// Validate required fields.
var failures []validate.FieldError
for i, mask := range [1]uint8{
0b00000111,
0b00111111,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.

@ -1601,9 +1601,12 @@ func decodeGetSubmissionParams(args [1]string, argsEscaped bool, r *http.Request
// ListMapfixesParams is parameters of listMapfixes operation.
type ListMapfixesParams struct {
Page int32
Limit int32
Sort OptInt32
Page int32
Limit int32
DisplayName OptString
Creator OptString
GameID OptInt32
Sort OptInt32
}
func unpackListMapfixesParams(packed middleware.Parameters) (params ListMapfixesParams) {
@ -1621,6 +1624,33 @@ func unpackListMapfixesParams(packed middleware.Parameters) (params ListMapfixes
}
params.Limit = packed[key].(int32)
}
{
key := middleware.ParameterKey{
Name: "DisplayName",
In: "query",
}
if v, ok := packed[key]; ok {
params.DisplayName = v.(OptString)
}
}
{
key := middleware.ParameterKey{
Name: "Creator",
In: "query",
}
if v, ok := packed[key]; ok {
params.Creator = v.(OptString)
}
}
{
key := middleware.ParameterKey{
Name: "GameID",
In: "query",
}
if v, ok := packed[key]; ok {
params.GameID = v.(OptInt32)
}
}
{
key := middleware.ParameterKey{
Name: "Sort",
@ -1741,6 +1771,175 @@ func decodeListMapfixesParams(args [0]string, argsEscaped bool, r *http.Request)
Err: err,
}
}
// Decode query: DisplayName.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "DisplayName",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotDisplayNameVal string
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToString(val)
if err != nil {
return err
}
paramsDotDisplayNameVal = c
return nil
}(); err != nil {
return err
}
params.DisplayName.SetTo(paramsDotDisplayNameVal)
return nil
}); err != nil {
return err
}
if err := func() error {
if value, ok := params.DisplayName.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "DisplayName",
In: "query",
Err: err,
}
}
// Decode query: Creator.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "Creator",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotCreatorVal string
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToString(val)
if err != nil {
return err
}
paramsDotCreatorVal = c
return nil
}(); err != nil {
return err
}
params.Creator.SetTo(paramsDotCreatorVal)
return nil
}); err != nil {
return err
}
if err := func() error {
if value, ok := params.Creator.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Creator",
In: "query",
Err: err,
}
}
// Decode query: GameID.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "GameID",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotGameIDVal int32
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt32(val)
if err != nil {
return err
}
paramsDotGameIDVal = c
return nil
}(); err != nil {
return err
}
params.GameID.SetTo(paramsDotGameIDVal)
return nil
}); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "GameID",
In: "query",
Err: err,
}
}
// Decode query: Sort.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{

@ -72,6 +72,14 @@ func (s *Server) decodeCreateMapfixRequest(r *http.Request) (
}
return req, close, err
}
if err := func() error {
if err := request.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return req, close, errors.Wrap(err, "validate")
}
return &request, close, nil
default:
return req, close, validate.InvalidContentType(ct)

@ -156,6 +156,9 @@ func (s *ID) SetID(val int64) {
// Ref: #/components/schemas/Mapfix
type Mapfix struct {
ID int64 `json:"ID"`
DisplayName string `json:"DisplayName"`
Creator string `json:"Creator"`
GameID int32 `json:"GameID"`
CreatedAt int64 `json:"CreatedAt"`
UpdatedAt int64 `json:"UpdatedAt"`
Submitter int64 `json:"Submitter"`
@ -172,6 +175,21 @@ func (s *Mapfix) GetID() int64 {
return s.ID
}
// GetDisplayName returns the value of DisplayName.
func (s *Mapfix) GetDisplayName() string {
return s.DisplayName
}
// GetCreator returns the value of Creator.
func (s *Mapfix) GetCreator() string {
return s.Creator
}
// GetGameID returns the value of GameID.
func (s *Mapfix) GetGameID() int32 {
return s.GameID
}
// GetCreatedAt returns the value of CreatedAt.
func (s *Mapfix) GetCreatedAt() int64 {
return s.CreatedAt
@ -222,6 +240,21 @@ func (s *Mapfix) SetID(val int64) {
s.ID = val
}
// SetDisplayName sets the value of DisplayName.
func (s *Mapfix) SetDisplayName(val string) {
s.DisplayName = val
}
// SetCreator sets the value of Creator.
func (s *Mapfix) SetCreator(val string) {
s.Creator = val
}
// SetGameID sets the value of GameID.
func (s *Mapfix) SetGameID(val int32) {
s.GameID = val
}
// SetCreatedAt sets the value of CreatedAt.
func (s *Mapfix) SetCreatedAt(val int64) {
s.CreatedAt = val
@ -269,9 +302,27 @@ func (s *Mapfix) SetStatusMessage(val string) {
// Ref: #/components/schemas/MapfixCreate
type MapfixCreate struct {
AssetID int64 `json:"AssetID"`
AssetVersion int64 `json:"AssetVersion"`
TargetAssetID int64 `json:"TargetAssetID"`
DisplayName string `json:"DisplayName"`
Creator string `json:"Creator"`
GameID int32 `json:"GameID"`
AssetID int64 `json:"AssetID"`
AssetVersion int64 `json:"AssetVersion"`
TargetAssetID int64 `json:"TargetAssetID"`
}
// GetDisplayName returns the value of DisplayName.
func (s *MapfixCreate) GetDisplayName() string {
return s.DisplayName
}
// GetCreator returns the value of Creator.
func (s *MapfixCreate) GetCreator() string {
return s.Creator
}
// GetGameID returns the value of GameID.
func (s *MapfixCreate) GetGameID() int32 {
return s.GameID
}
// GetAssetID returns the value of AssetID.
@ -289,6 +340,21 @@ func (s *MapfixCreate) GetTargetAssetID() int64 {
return s.TargetAssetID
}
// SetDisplayName sets the value of DisplayName.
func (s *MapfixCreate) SetDisplayName(val string) {
s.DisplayName = val
}
// SetCreator sets the value of Creator.
func (s *MapfixCreate) SetCreator(val string) {
s.Creator = val
}
// SetGameID sets the value of GameID.
func (s *MapfixCreate) SetGameID(val int32) {
s.GameID = val
}
// SetAssetID sets the value of AssetID.
func (s *MapfixCreate) SetAssetID(val int64) {
s.AssetID = val

@ -14,6 +14,44 @@ func (s *Mapfix) Validate() error {
}
var failures []validate.FieldError
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(s.DisplayName)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "DisplayName",
Error: err,
})
}
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(s.Creator)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Creator",
Error: err,
})
}
if err := func() error {
if err := (validate.String{
MinLength: 0,
@ -39,6 +77,56 @@ func (s *Mapfix) Validate() error {
return nil
}
func (s *MapfixCreate) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(s.DisplayName)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "DisplayName",
Error: err,
})
}
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(s.Creator)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Creator",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *Script) Validate() error {
if s == nil {
return validate.ErrNilPointer