openapi: generate
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Quaternions 2024-12-17 20:42:31 -08:00
parent fe0a1e0e0f
commit a28ec58ce8
2 changed files with 8 additions and 97 deletions

View File

@ -1307,12 +1307,6 @@ func (s *ScriptPolicyFilter) Encode(e *jx.Encoder) {
// encodeFields encodes fields. // encodeFields encodes fields.
func (s *ScriptPolicyFilter) encodeFields(e *jx.Encoder) { func (s *ScriptPolicyFilter) encodeFields(e *jx.Encoder) {
{
if s.ID.Set {
e.FieldStart("ID")
s.ID.Encode(e)
}
}
{ {
if s.FromScriptHash.Set { if s.FromScriptHash.Set {
e.FieldStart("FromScriptHash") e.FieldStart("FromScriptHash")
@ -1333,11 +1327,10 @@ func (s *ScriptPolicyFilter) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfScriptPolicyFilter = [4]string{ var jsonFieldsNameOfScriptPolicyFilter = [3]string{
0: "ID", 0: "FromScriptHash",
1: "FromScriptHash", 1: "ToScriptID",
2: "ToScriptID", 2: "Policy",
3: "Policy",
} }
// Decode decodes ScriptPolicyFilter from json. // Decode decodes ScriptPolicyFilter from json.
@ -1348,16 +1341,6 @@ func (s *ScriptPolicyFilter) 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 "ID":
if err := func() error {
s.ID.Reset()
if err := s.ID.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"ID\"")
}
case "FromScriptHash": case "FromScriptHash":
if err := func() error { if err := func() error {
s.FromScriptHash.Reset() s.FromScriptHash.Reset()
@ -2197,10 +2180,6 @@ func (s *SubmissionFilter) Encode(e *jx.Encoder) {
// encodeFields encodes fields. // encodeFields encodes fields.
func (s *SubmissionFilter) encodeFields(e *jx.Encoder) { func (s *SubmissionFilter) encodeFields(e *jx.Encoder) {
{
e.FieldStart("ID")
e.Int64(s.ID)
}
{ {
if s.DisplayName.Set { if s.DisplayName.Set {
e.FieldStart("DisplayName") e.FieldStart("DisplayName")
@ -2221,11 +2200,10 @@ func (s *SubmissionFilter) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfSubmissionFilter = [4]string{ var jsonFieldsNameOfSubmissionFilter = [3]string{
0: "ID", 0: "DisplayName",
1: "DisplayName", 1: "Creator",
2: "Creator", 2: "GameID",
3: "GameID",
} }
// Decode decodes SubmissionFilter from json. // Decode decodes SubmissionFilter from json.
@ -2233,22 +2211,9 @@ func (s *SubmissionFilter) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode SubmissionFilter to nil") return errors.New("invalid: unable to decode SubmissionFilter to nil")
} }
var requiredBitSet [1]uint8
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 "ID":
requiredBitSet[0] |= 1 << 0
if err := func() error {
v, err := d.Int64()
s.ID = int64(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"ID\"")
}
case "DisplayName": case "DisplayName":
if err := func() error { if err := func() error {
s.DisplayName.Reset() s.DisplayName.Reset()
@ -2286,38 +2251,6 @@ func (s *SubmissionFilter) Decode(d *jx.Decoder) error {
}); err != nil { }); err != nil {
return errors.Wrap(err, "decode SubmissionFilter") return errors.Wrap(err, "decode SubmissionFilter")
} }
// Validate required fields.
var failures []validate.FieldError
for i, mask := range [1]uint8{
0b00000001,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.
//
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
// Bits of fields which would be set are actually bits of missed fields.
missed := bits.OnesCount8(result)
for bitN := 0; bitN < missed; bitN++ {
bitIdx := bits.TrailingZeros8(result)
fieldIdx := i*8 + bitIdx
var name string
if fieldIdx < len(jsonFieldsNameOfSubmissionFilter) {
name = jsonFieldsNameOfSubmissionFilter[fieldIdx]
} else {
name = strconv.Itoa(fieldIdx)
}
failures = append(failures, validate.FieldError{
Name: name,
Error: validate.ErrFieldRequired,
})
// Reset bit.
result &^= 1 << bitIdx
}
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil return nil
} }

View File

@ -605,17 +605,11 @@ func (s *ScriptPolicyCreate) SetPolicy(val int32) {
// Ref: #/components/schemas/ScriptPolicyFilter // Ref: #/components/schemas/ScriptPolicyFilter
type ScriptPolicyFilter struct { type ScriptPolicyFilter struct {
ID OptInt64 `json:"ID"`
FromScriptHash OptString `json:"FromScriptHash"` FromScriptHash OptString `json:"FromScriptHash"`
ToScriptID OptInt64 `json:"ToScriptID"` ToScriptID OptInt64 `json:"ToScriptID"`
Policy OptInt32 `json:"Policy"` Policy OptInt32 `json:"Policy"`
} }
// GetID returns the value of ID.
func (s *ScriptPolicyFilter) GetID() OptInt64 {
return s.ID
}
// GetFromScriptHash returns the value of FromScriptHash. // GetFromScriptHash returns the value of FromScriptHash.
func (s *ScriptPolicyFilter) GetFromScriptHash() OptString { func (s *ScriptPolicyFilter) GetFromScriptHash() OptString {
return s.FromScriptHash return s.FromScriptHash
@ -631,11 +625,6 @@ func (s *ScriptPolicyFilter) GetPolicy() OptInt32 {
return s.Policy return s.Policy
} }
// SetID sets the value of ID.
func (s *ScriptPolicyFilter) SetID(val OptInt64) {
s.ID = val
}
// SetFromScriptHash sets the value of FromScriptHash. // SetFromScriptHash sets the value of FromScriptHash.
func (s *ScriptPolicyFilter) SetFromScriptHash(val OptString) { func (s *ScriptPolicyFilter) SetFromScriptHash(val OptString) {
s.FromScriptHash = val s.FromScriptHash = val
@ -969,17 +958,11 @@ func (s *SubmissionCreate) SetTargetAssetID(val OptInt64) {
// Ref: #/components/schemas/SubmissionFilter // Ref: #/components/schemas/SubmissionFilter
type SubmissionFilter struct { type SubmissionFilter struct {
ID int64 `json:"ID"`
DisplayName OptString `json:"DisplayName"` DisplayName OptString `json:"DisplayName"`
Creator OptString `json:"Creator"` Creator OptString `json:"Creator"`
GameID OptInt32 `json:"GameID"` GameID OptInt32 `json:"GameID"`
} }
// GetID returns the value of ID.
func (s *SubmissionFilter) GetID() int64 {
return s.ID
}
// GetDisplayName returns the value of DisplayName. // GetDisplayName returns the value of DisplayName.
func (s *SubmissionFilter) GetDisplayName() OptString { func (s *SubmissionFilter) GetDisplayName() OptString {
return s.DisplayName return s.DisplayName
@ -995,11 +978,6 @@ func (s *SubmissionFilter) GetGameID() OptInt32 {
return s.GameID return s.GameID
} }
// SetID sets the value of ID.
func (s *SubmissionFilter) SetID(val int64) {
s.ID = val
}
// SetDisplayName sets the value of DisplayName. // SetDisplayName sets the value of DisplayName.
func (s *SubmissionFilter) SetDisplayName(val OptString) { func (s *SubmissionFilter) SetDisplayName(val OptString) {
s.DisplayName = val s.DisplayName = val