openapi: generate

This commit is contained in:
Quaternions 2025-04-11 12:29:16 -07:00
parent d1ca9bdab9
commit 1ff6bdbd4c
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131
6 changed files with 119 additions and 71 deletions

@ -602,8 +602,8 @@ func (s *Mapfix) encodeFields(e *jx.Encoder) {
e.Int32(s.StatusID)
}
{
e.FieldStart("StatusMessage")
e.Str(s.StatusMessage)
e.FieldStart("Description")
e.Str(s.Description)
}
}
@ -620,7 +620,7 @@ var jsonFieldsNameOfMapfix = [13]string{
9: "Completed",
10: "TargetAssetID",
11: "StatusID",
12: "StatusMessage",
12: "Description",
}
// Decode decodes Mapfix from json.
@ -776,17 +776,17 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"StatusID\"")
}
case "StatusMessage":
case "Description":
requiredBitSet[1] |= 1 << 4
if err := func() error {
v, err := d.Str()
s.StatusMessage = string(v)
s.Description = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"StatusMessage\"")
return errors.Wrap(err, "decode field \"Description\"")
}
default:
return d.Skip()
@ -862,11 +862,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 +907,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 +929,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.
@ -2851,13 +2868,9 @@ func (s *Submission) encodeFields(e *jx.Encoder) {
e.FieldStart("StatusID")
e.Int32(s.StatusID)
}
{
e.FieldStart("StatusMessage")
e.Str(s.StatusMessage)
}
}
var jsonFieldsNameOfSubmission = [15]string{
var jsonFieldsNameOfSubmission = [14]string{
0: "ID",
1: "DisplayName",
2: "Creator",
@ -2872,7 +2885,6 @@ var jsonFieldsNameOfSubmission = [15]string{
11: "Completed",
12: "UploadedAssetID",
13: "StatusID",
14: "StatusMessage",
}
// Decode decodes Submission from json.
@ -3046,18 +3058,6 @@ func (s *Submission) Decode(d *jx.Decoder) error {
}(); err != nil {
return errors.Wrap(err, "decode field \"StatusID\"")
}
case "StatusMessage":
requiredBitSet[1] |= 1 << 6
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()
}
@ -3069,7 +3069,7 @@ func (s *Submission) Decode(d *jx.Decoder) error {
var failures []validate.FieldError
for i, mask := range [2]uint8{
0b11111111,
0b01101001,
0b00101001,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.

@ -349,7 +349,7 @@ type Mapfix struct {
Completed bool `json:"Completed"`
TargetAssetID int64 `json:"TargetAssetID"`
StatusID int32 `json:"StatusID"`
StatusMessage string `json:"StatusMessage"`
Description string `json:"Description"`
}
// GetID returns the value of ID.
@ -412,9 +412,9 @@ func (s *Mapfix) GetStatusID() int32 {
return s.StatusID
}
// GetStatusMessage returns the value of StatusMessage.
func (s *Mapfix) GetStatusMessage() string {
return s.StatusMessage
// GetDescription returns the value of Description.
func (s *Mapfix) GetDescription() string {
return s.Description
}
// SetID sets the value of ID.
@ -477,15 +477,16 @@ func (s *Mapfix) SetStatusID(val int32) {
s.StatusID = val
}
// SetStatusMessage sets the value of StatusMessage.
func (s *Mapfix) SetStatusMessage(val string) {
s.StatusMessage = val
// SetDescription sets the value of Description.
func (s *Mapfix) SetDescription(val string) {
s.Description = 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 +499,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 +514,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"`
@ -1163,7 +1174,6 @@ type Submission struct {
Completed bool `json:"Completed"`
UploadedAssetID OptInt64 `json:"UploadedAssetID"`
StatusID int32 `json:"StatusID"`
StatusMessage string `json:"StatusMessage"`
}
// GetID returns the value of ID.
@ -1236,11 +1246,6 @@ func (s *Submission) GetStatusID() int32 {
return s.StatusID
}
// GetStatusMessage returns the value of StatusMessage.
func (s *Submission) GetStatusMessage() string {
return s.StatusMessage
}
// SetID sets the value of ID.
func (s *Submission) SetID(val int64) {
s.ID = val
@ -1311,11 +1316,6 @@ func (s *Submission) SetStatusID(val int32) {
s.StatusID = val
}
// SetStatusMessage sets the value of StatusMessage.
func (s *Submission) SetStatusMessage(val string) {
s.StatusMessage = val
}
// Ref: #/components/schemas/SubmissionTriggerCreate
type SubmissionTriggerCreate struct {
AssetID int64 `json:"AssetID"`

@ -408,13 +408,13 @@ func (s *Mapfix) Validate() error {
Email: false,
Hostname: false,
Regex: nil,
}).Validate(string(s.StatusMessage)); err != nil {
}).Validate(string(s.Description)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "StatusMessage",
Name: "Description",
Error: err,
})
}
@ -470,6 +470,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}
}
@ -1751,25 +1770,6 @@ func (s *Submission) 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}
}

@ -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}
}