From d85a5a0669b6f08aa99b41f9f8a7bfd4f56ae715 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 26 Nov 2024 14:47:56 -0800 Subject: [PATCH] run generate --- api/oas_json_gen.go | 166 +++++++++++++++++++++++++++++++++++++++-- api/oas_schemas_gen.go | 133 +++++++++++++++++++++++++++++++-- 2 files changed, 288 insertions(+), 11 deletions(-) diff --git a/api/oas_json_gen.go b/api/oas_json_gen.go index 8102003..7ab9de0 100644 --- a/api/oas_json_gen.go +++ b/api/oas_json_gen.go @@ -125,6 +125,41 @@ func (s *Error) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes bool as json. +func (o OptBool) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Bool(bool(o.Value)) +} + +// Decode decodes bool from json. +func (o *OptBool) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptBool to nil") + } + o.Set = true + v, err := d.Bool() + if err != nil { + return err + } + o.Value = bool(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptBool) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptBool) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes int32 as json. func (o OptInt32) Encode(e *jx.Encoder) { if !o.Set { @@ -269,14 +304,63 @@ func (s *Submission) encodeFields(e *jx.Encoder) { s.Date.Encode(e) } } + { + if s.Submitter.Set { + e.FieldStart("Submitter") + s.Submitter.Encode(e) + } + } + { + if s.AssetID.Set { + e.FieldStart("AssetID") + s.AssetID.Encode(e) + } + } + { + if s.AssetVersion.Set { + e.FieldStart("AssetVersion") + s.AssetVersion.Encode(e) + } + } + { + if s.Completed.Set { + e.FieldStart("Completed") + s.Completed.Encode(e) + } + } + { + if s.SubmissionType.Set { + e.FieldStart("SubmissionType") + s.SubmissionType.Encode(e) + } + } + { + if s.TargetAssetID.Set { + e.FieldStart("TargetAssetID") + s.TargetAssetID.Encode(e) + } + } + { + if s.StatusID.Set { + e.FieldStart("StatusID") + s.StatusID.Encode(e) + } + } } -var jsonFieldsNameOfSubmission = [5]string{ - 0: "ID", - 1: "DisplayName", - 2: "Creator", - 3: "GameID", - 4: "Date", +var jsonFieldsNameOfSubmission = [12]string{ + 0: "ID", + 1: "DisplayName", + 2: "Creator", + 3: "GameID", + 4: "Date", + 5: "Submitter", + 6: "AssetID", + 7: "AssetVersion", + 8: "Completed", + 9: "SubmissionType", + 10: "TargetAssetID", + 11: "StatusID", } // Decode decodes Submission from json. @@ -337,6 +421,76 @@ func (s *Submission) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"Date\"") } + case "Submitter": + if err := func() error { + s.Submitter.Reset() + if err := s.Submitter.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"Submitter\"") + } + case "AssetID": + if err := func() error { + s.AssetID.Reset() + if err := s.AssetID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"AssetID\"") + } + case "AssetVersion": + if err := func() error { + s.AssetVersion.Reset() + if err := s.AssetVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"AssetVersion\"") + } + case "Completed": + if err := func() error { + s.Completed.Reset() + if err := s.Completed.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"Completed\"") + } + case "SubmissionType": + if err := func() error { + s.SubmissionType.Reset() + if err := s.SubmissionType.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"SubmissionType\"") + } + case "TargetAssetID": + if err := func() error { + s.TargetAssetID.Reset() + if err := s.TargetAssetID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"TargetAssetID\"") + } + case "StatusID": + if err := func() error { + s.StatusID.Reset() + if err := s.StatusID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"StatusID\"") + } default: return d.Skip() } diff --git a/api/oas_schemas_gen.go b/api/oas_schemas_gen.go index 3c7ba0c..b517dd6 100644 --- a/api/oas_schemas_gen.go +++ b/api/oas_schemas_gen.go @@ -63,6 +63,52 @@ func (s *ErrorStatusCode) SetResponse(val Error) { s.Response = val } +// NewOptBool returns new OptBool with value set to v. +func NewOptBool(v bool) OptBool { + return OptBool{ + Value: v, + Set: true, + } +} + +// OptBool is optional bool. +type OptBool struct { + Value bool + Set bool +} + +// IsSet returns true if OptBool was set. +func (o OptBool) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptBool) Reset() { + var v bool + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptBool) SetTo(v bool) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptBool) Get() (v bool, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptBool) Or(d bool) bool { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptInt32 returns new OptInt32 with value set to v. func NewOptInt32(v int32) OptInt32 { return OptInt32{ @@ -284,11 +330,18 @@ type PatchSubmissionStatusOK struct{} // Ref: #/components/schemas/Submission type Submission struct { - ID OptInt64 `json:"ID"` - DisplayName OptString `json:"DisplayName"` - Creator OptString `json:"Creator"` - GameID OptInt32 `json:"GameID"` - Date OptInt64 `json:"Date"` + ID OptInt64 `json:"ID"` + DisplayName OptString `json:"DisplayName"` + Creator OptString `json:"Creator"` + GameID OptInt32 `json:"GameID"` + Date OptInt64 `json:"Date"` + Submitter OptInt64 `json:"Submitter"` + AssetID OptInt64 `json:"AssetID"` + AssetVersion OptInt64 `json:"AssetVersion"` + Completed OptBool `json:"Completed"` + SubmissionType OptInt32 `json:"SubmissionType"` + TargetAssetID OptInt64 `json:"TargetAssetID"` + StatusID OptInt32 `json:"StatusID"` } // GetID returns the value of ID. @@ -316,6 +369,41 @@ func (s *Submission) GetDate() OptInt64 { return s.Date } +// GetSubmitter returns the value of Submitter. +func (s *Submission) GetSubmitter() OptInt64 { + return s.Submitter +} + +// GetAssetID returns the value of AssetID. +func (s *Submission) GetAssetID() OptInt64 { + return s.AssetID +} + +// GetAssetVersion returns the value of AssetVersion. +func (s *Submission) GetAssetVersion() OptInt64 { + return s.AssetVersion +} + +// GetCompleted returns the value of Completed. +func (s *Submission) GetCompleted() OptBool { + return s.Completed +} + +// GetSubmissionType returns the value of SubmissionType. +func (s *Submission) GetSubmissionType() OptInt32 { + return s.SubmissionType +} + +// GetTargetAssetID returns the value of TargetAssetID. +func (s *Submission) GetTargetAssetID() OptInt64 { + return s.TargetAssetID +} + +// GetStatusID returns the value of StatusID. +func (s *Submission) GetStatusID() OptInt32 { + return s.StatusID +} + // SetID sets the value of ID. func (s *Submission) SetID(val OptInt64) { s.ID = val @@ -341,6 +429,41 @@ func (s *Submission) SetDate(val OptInt64) { s.Date = val } +// SetSubmitter sets the value of Submitter. +func (s *Submission) SetSubmitter(val OptInt64) { + s.Submitter = val +} + +// SetAssetID sets the value of AssetID. +func (s *Submission) SetAssetID(val OptInt64) { + s.AssetID = val +} + +// SetAssetVersion sets the value of AssetVersion. +func (s *Submission) SetAssetVersion(val OptInt64) { + s.AssetVersion = val +} + +// SetCompleted sets the value of Completed. +func (s *Submission) SetCompleted(val OptBool) { + s.Completed = val +} + +// SetSubmissionType sets the value of SubmissionType. +func (s *Submission) SetSubmissionType(val OptInt32) { + s.SubmissionType = val +} + +// SetTargetAssetID sets the value of TargetAssetID. +func (s *Submission) SetTargetAssetID(val OptInt64) { + s.TargetAssetID = val +} + +// SetStatusID sets the value of StatusID. +func (s *Submission) SetStatusID(val OptInt32) { + s.StatusID = val +} + // Ref: #/components/schemas/SubmissionFilter type SubmissionFilter struct { ID OptInt64 `json:"ID"`