openapi: generate

This commit is contained in:
Quaternions 2025-04-11 12:29:16 -07:00
parent 21c17591a2
commit e6806585d3
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131
6 changed files with 104 additions and 56 deletions

@ -601,13 +601,9 @@ func (s *Mapfix) encodeFields(e *jx.Encoder) {
e.FieldStart("StatusID")
e.Int32(s.StatusID)
}
{
e.FieldStart("StatusMessage")
e.Str(s.StatusMessage)
}
}
var jsonFieldsNameOfMapfix = [13]string{
var jsonFieldsNameOfMapfix = [12]string{
0: "ID",
1: "DisplayName",
2: "Creator",
@ -620,7 +616,6 @@ var jsonFieldsNameOfMapfix = [13]string{
9: "Completed",
10: "TargetAssetID",
11: "StatusID",
12: "StatusMessage",
}
// Decode decodes Mapfix from json.
@ -776,18 +771,6 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"StatusID\"")
}
case "StatusMessage":
requiredBitSet[1] |= 1 << 4
if err := func() error {
v, err := d.Str()
s.StatusMessage = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"StatusMessage\"")
}
default:
return d.Skip()
}
@ -799,7 +782,7 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
var failures []validate.FieldError
for i, mask := range [2]uint8{
0b11111111,
0b00011111,
0b00001111,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.
@ -862,11 +845,16 @@ func (s *MapfixTriggerCreate) encodeFields(e *jx.Encoder) {
e.FieldStart("TargetAssetID")
e.Int64(s.TargetAssetID)
}
{
e.FieldStart("Description")
e.Str(s.Description)
}
}
var jsonFieldsNameOfMapfixTriggerCreate = [2]string{
var jsonFieldsNameOfMapfixTriggerCreate = [3]string{
0: "AssetID",
1: "TargetAssetID",
2: "Description",
}
// Decode decodes MapfixTriggerCreate from json.
@ -902,6 +890,18 @@ func (s *MapfixTriggerCreate) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"TargetAssetID\"")
}
case "Description":
requiredBitSet[0] |= 1 << 2
if err := func() error {
v, err := d.Str()
s.Description = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Description\"")
}
default:
return d.Skip()
}
@ -912,7 +912,7 @@ func (s *MapfixTriggerCreate) Decode(d *jx.Decoder) error {
// Validate required fields.
var failures []validate.FieldError
for i, mask := range [1]uint8{
0b00000011,
0b00000111,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.

@ -349,7 +349,6 @@ type Mapfix struct {
Completed bool `json:"Completed"`
TargetAssetID int64 `json:"TargetAssetID"`
StatusID int32 `json:"StatusID"`
StatusMessage string `json:"StatusMessage"`
}
// GetID returns the value of ID.
@ -412,11 +411,6 @@ func (s *Mapfix) GetStatusID() int32 {
return s.StatusID
}
// GetStatusMessage returns the value of StatusMessage.
func (s *Mapfix) GetStatusMessage() string {
return s.StatusMessage
}
// SetID sets the value of ID.
func (s *Mapfix) SetID(val int64) {
s.ID = val
@ -477,15 +471,11 @@ func (s *Mapfix) SetStatusID(val int32) {
s.StatusID = val
}
// SetStatusMessage sets the value of StatusMessage.
func (s *Mapfix) SetStatusMessage(val string) {
s.StatusMessage = val
}
// Ref: #/components/schemas/MapfixTriggerCreate
type MapfixTriggerCreate struct {
AssetID int64 `json:"AssetID"`
TargetAssetID int64 `json:"TargetAssetID"`
AssetID int64 `json:"AssetID"`
TargetAssetID int64 `json:"TargetAssetID"`
Description string `json:"Description"`
}
// GetAssetID returns the value of AssetID.
@ -498,6 +488,11 @@ func (s *MapfixTriggerCreate) GetTargetAssetID() int64 {
return s.TargetAssetID
}
// GetDescription returns the value of Description.
func (s *MapfixTriggerCreate) GetDescription() string {
return s.Description
}
// SetAssetID sets the value of AssetID.
func (s *MapfixTriggerCreate) SetAssetID(val int64) {
s.AssetID = val
@ -508,6 +503,11 @@ func (s *MapfixTriggerCreate) SetTargetAssetID(val int64) {
s.TargetAssetID = val
}
// SetDescription sets the value of Description.
func (s *MapfixTriggerCreate) SetDescription(val string) {
s.Description = val
}
// Ref: #/components/schemas/Mapfixes
type Mapfixes struct {
Total int64 `json:"Total"`

@ -399,25 +399,6 @@ func (s *Mapfix) Validate() error {
Error: err,
})
}
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 256,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(s.StatusMessage)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "StatusMessage",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
@ -470,6 +451,25 @@ func (s *MapfixTriggerCreate) Validate() error {
Error: err,
})
}
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 256,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(s.Description)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Description",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}

@ -166,9 +166,13 @@ func (s *MapfixCreate) encodeFields(e *jx.Encoder) {
e.FieldStart("TargetAssetID")
e.Int64(s.TargetAssetID)
}
{
e.FieldStart("Description")
e.Str(s.Description)
}
}
var jsonFieldsNameOfMapfixCreate = [8]string{
var jsonFieldsNameOfMapfixCreate = [9]string{
0: "OperationID",
1: "AssetOwner",
2: "DisplayName",
@ -177,6 +181,7 @@ var jsonFieldsNameOfMapfixCreate = [8]string{
5: "AssetID",
6: "AssetVersion",
7: "TargetAssetID",
8: "Description",
}
// Decode decodes MapfixCreate from json.
@ -184,7 +189,7 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode MapfixCreate to nil")
}
var requiredBitSet [1]uint8
var requiredBitSet [2]uint8
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) {
@ -284,6 +289,18 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"TargetAssetID\"")
}
case "Description":
requiredBitSet[1] |= 1 << 0
if err := func() error {
v, err := d.Str()
s.Description = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"Description\"")
}
default:
return d.Skip()
}
@ -293,8 +310,9 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
}
// Validate required fields.
var failures []validate.FieldError
for i, mask := range [1]uint8{
for i, mask := range [2]uint8{
0b11111111,
0b00000001,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.

@ -106,6 +106,7 @@ type MapfixCreate struct {
AssetID int64 `json:"AssetID"`
AssetVersion int64 `json:"AssetVersion"`
TargetAssetID int64 `json:"TargetAssetID"`
Description string `json:"Description"`
}
// GetOperationID returns the value of OperationID.
@ -148,6 +149,11 @@ func (s *MapfixCreate) GetTargetAssetID() int64 {
return s.TargetAssetID
}
// GetDescription returns the value of Description.
func (s *MapfixCreate) GetDescription() string {
return s.Description
}
// SetOperationID sets the value of OperationID.
func (s *MapfixCreate) SetOperationID(val int32) {
s.OperationID = val
@ -188,6 +194,11 @@ func (s *MapfixCreate) SetTargetAssetID(val int64) {
s.TargetAssetID = val
}
// SetDescription sets the value of Description.
func (s *MapfixCreate) SetDescription(val string) {
s.Description = val
}
// Ref: #/components/schemas/MapfixID
type MapfixID struct {
MapfixID int64 `json:"MapfixID"`

@ -227,6 +227,25 @@ func (s *MapfixCreate) Validate() error {
Error: err,
})
}
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 256,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(s.Description)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Description",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}