github.com/youyuanwu/go-swagger@v0.19.0/fixtures/goparsing/classification/models/nomodel.go (about) 1 // Copyright 2015 go-swagger maintainers 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package models 16 17 import ( 18 "time" 19 20 "github.com/go-openapi/strfmt" 21 "github.com/go-swagger/go-swagger/fixtures/goparsing/classification/transitive/mods" 22 ) 23 24 // NoModel is a struct without an annotation. 25 // NoModel exists in a package 26 // but is not annotated with the swagger model annotations 27 // so it should now show up in a test. 28 // 29 type NoModel struct { 30 // ID of this no model instance. 31 // ids in this application start at 11 and are smaller than 1000 32 // 33 // required: true 34 // minimum: > 10 35 // maximum: < 1000 36 // default: 11 37 ID int64 `json:"id"` 38 39 Ignored string `json:"-"` 40 IgnoredOther string `json:"-,omitempty"` 41 42 // A field which has omitempty set but no name 43 NoNameOmitEmpty string `json:",omitempty"` 44 45 // The Score of this model 46 // 47 // required: true 48 // minimum: 3 49 // maximum: 45 50 // multiple of: 3 51 // example: 27 52 Score int32 `json:"score"` 53 54 // Name of this no model instance 55 // 56 // min length: 4 57 // max length: 50 58 // pattern: [A-Za-z0-9-.]* 59 // required: true 60 // 61 // Extensions: 62 // --- 63 // x-property-value: value 64 // x-property-array: 65 // - value1 66 // - value2 67 // x-property-array-obj: 68 // - name: obj 69 // value: field 70 // --- 71 // 72 Name string `json:"name"` 73 74 // Created holds the time when this entry was created 75 // 76 // required: false 77 // read only: true 78 Created strfmt.DateTime `json:"created"` 79 80 // GoTimeCreated holds the time when this entry was created in go time.Time 81 // 82 // required: false 83 GoTimeCreated time.Time `json:"gocreated"` 84 85 // a FooSlice has foos which are strings 86 // 87 // min items: 3 88 // max items: 10 89 // unique: true 90 // items.minLength: 3 91 // items.maxLength: 10 92 // items.pattern: \w+ 93 FooSlice []string `json:"foo_slice"` 94 95 // a TimeSlice is a slice of times 96 // 97 // min items: 3 98 // max items: 10 99 // unique: true 100 TimeSlice []time.Time `json:"time_slice"` 101 102 // a BarSlice has bars which are strings 103 // 104 // min items: 3 105 // max items: 10 106 // unique: true 107 // items.minItems: 4 108 // items.maxItems: 9 109 // items.items.minItems: 5 110 // items.items.maxItems: 8 111 // items.items.items.minLength: 3 112 // items.items.items.maxLength: 10 113 // items.items.items.pattern: \w+ 114 BarSlice [][][]string `json:"bar_slice"` 115 116 // a DeepSlice has bars which are time 117 // 118 // min items: 3 119 // max items: 10 120 // unique: true 121 // items.minItems: 4 122 // items.maxItems: 9 123 // items.items.minItems: 5 124 // items.items.maxItems: 8 125 DeepTimeSlice [][][]time.Time `json:"deep_time_slice"` 126 127 // the items for this order 128 Items []struct { 129 // ID of this no model instance. 130 // ids in this application start at 11 and are smaller than 1000 131 // 132 // required: true 133 // minimum: > 10 134 // maximum: < 1000 135 // default: 11 136 ID int32 `json:"id"` 137 138 // The Pet to add to this NoModel items bucket. 139 // Pets can appear more than once in the bucket 140 // 141 // required: true 142 Pet *mods.Pet `json:"pet"` 143 144 // The amount of pets to add to this bucket. 145 // 146 // required: true 147 // minimum: 1 148 // maximum: 10 149 Quantity int16 `json:"quantity"` 150 151 // A dummy expiration date. 152 // 153 // required: true 154 Expiration time.Time `json:"expiration"` 155 156 // Notes to add to this item. 157 // This can be used to add special instructions. 158 // 159 // required: false 160 Notes string `json:"notes"` 161 162 AlsoIgnored string `json:"-"` 163 } `json:"items"` 164 } 165 166 // A OtherTypes struct contains type aliases 167 type OtherTypes struct { 168 Named SomeStringType `json:"named"` 169 Numbered SomeIntType `json:"numbered"` 170 Dated SomeTimeType `json:"dated"` 171 Timed SomeTimedType `json:"timed"` 172 Petted SomePettedType `json:"petted"` 173 Somethinged SomethingType `json:"somethinged"` 174 StrMap SomeStringMap `json:"strMap"` 175 StrArrMap SomeArrayStringMap `json:"strArrMap"` 176 177 ManyNamed SomeStringsType `json:"manyNamed"` 178 ManyNumbered SomeIntsType `json:"manyNumbered"` 179 ManyDated SomeTimesType `json:"manyDated"` 180 ManyTimed SomeTimedsType `json:"manyTimed"` 181 ManyPetted SomePettedsType `json:"manyPetted"` 182 ManySomethinged SomethingsType `json:"manySomethinged"` 183 184 Nameds []SomeStringType `json:"nameds"` 185 Numbereds []SomeIntType `json:"numbereds"` 186 Dateds []SomeTimeType `json:"dateds"` 187 Timeds []SomeTimedType `json:"timeds"` 188 Petteds []SomePettedType `json:"petteds"` 189 Somethingeds []SomethingType `json:"somethingeds"` 190 191 ModsNamed mods.SomeStringType `json:"modsNamed"` 192 ModsNumbered mods.SomeIntType `json:"modsNumbered"` 193 ModsDated mods.SomeTimeType `json:"modsDated"` 194 ModsTimed mods.SomeTimedType `json:"modsTimed"` 195 ModsPetted mods.SomePettedType `json:"modsPetted"` 196 197 ModsNameds []mods.SomeStringType `json:"modsNameds"` 198 ModsNumbereds []mods.SomeIntType `json:"modsNumbereds"` 199 ModsDateds []mods.SomeTimeType `json:"modsDateds"` 200 ModsTimeds []mods.SomeTimedType `json:"modsTimeds"` 201 ModsPetteds []mods.SomePettedType `json:"modsPetteds"` 202 203 ManyModsNamed mods.SomeStringsType `json:"manyModsNamed"` 204 ManyModsNumbered mods.SomeIntsType `json:"manyModsNumbered"` 205 ManyModsDated mods.SomeTimesType `json:"manyModsDated"` 206 ManyModsTimed mods.SomeTimedsType `json:"manyModsTimed"` 207 ManyModsPetted mods.SomePettedsType `json:"manyModsPetted"` 208 ManyModsPettedPtr mods.SomePettedsPtrType `json:"manyModsPettedPtr"` 209 210 NamedAlias SomeStringTypeAlias `json:"namedAlias"` 211 NumberedAlias SomeIntTypeAlias `json:"numberedAlias"` 212 NamedsAlias []SomeStringTypeAlias `json:"namedsAlias"` 213 NumberedsAlias []SomeIntTypeAlias `json:"numberedsAlias"` 214 } 215 216 // A SimpleOne is a model with a few simple fields 217 type SimpleOne struct { 218 ID int64 `json:"id"` 219 Name string `json:"name"` 220 Age int32 `json:"age"` 221 } 222 223 // A ComplexerOne is composed of a SimpleOne and some extra fields 224 type ComplexerOne struct { 225 SimpleOne 226 mods.NotSelected 227 mods.Notable 228 CreatedAt strfmt.DateTime `json:"createdAt"` 229 } 230 231 // An OverridingOne is composed of a SimpleOne and overrides a field 232 type OverridingOne struct { 233 SimpleOne 234 Age int64 235 } 236 237 // An OverridingOneIgnore is composed of a SimpleOne and overrides a field to ignore it 238 type OverridingOneIgnore struct { 239 SimpleOne 240 Age int32 `json:"-"` 241 } 242 243 // An AllOfModel is composed out of embedded structs but it should build 244 // an allOf property 245 type AllOfModel struct { 246 // swagger:allOf 247 SimpleOne 248 // swagger:allOf 249 mods.Notable 250 251 Something // not annotated with anything, so should be included 252 253 CreatedAt strfmt.DateTime `json:"createdAt"` 254 } 255 256 // An Embedded is to be embedded in EmbeddedStarExpr 257 type Embedded struct { 258 EmbeddedMember int64 `json:"embeddedMember"` 259 } 260 261 // An EmbeddedStarExpr for testing the embedded StarExpr 262 type EmbeddedStarExpr struct { 263 *Embedded 264 NotEmbedded int64 `json:"notEmbedded"` 265 } 266 267 // A PrimateModel is a struct with nothing but builtins. 268 // 269 // It only has values 1 level deep and each of those is of a very simple 270 // builtin type. 271 type PrimateModel struct { 272 A bool `json:"a"` 273 274 B rune `json:"b"` 275 C string `json:"c"` 276 277 D int `json:"d"` 278 E int8 `json:"e"` 279 F int16 `json:"f"` 280 G int32 `json:"g"` 281 H int64 `json:"h"` 282 283 I uint `json:"i"` 284 J uint8 `json:"j"` 285 K uint16 `json:"k"` 286 L uint32 `json:"l"` 287 M uint64 `json:"m"` 288 289 N float32 `json:"n"` 290 O float64 `json:"o"` 291 292 P byte `json:"p"` 293 294 Q uintptr `json:"q"` 295 } 296 297 // A FormattedModel is a struct with only strfmt types 298 // 299 // It only has values 1 level deep and is used for testing the conversion 300 type FormattedModel struct { 301 A strfmt.Base64 `json:"a"` 302 B strfmt.CreditCard `json:"b"` 303 C strfmt.Date `json:"c"` 304 D strfmt.DateTime `json:"d"` 305 E strfmt.Duration `json:"e"` 306 F strfmt.Email `json:"f"` 307 G strfmt.HexColor `json:"g"` 308 H strfmt.Hostname `json:"h"` 309 I strfmt.IPv4 `json:"i"` 310 J strfmt.IPv6 `json:"j"` 311 K strfmt.ISBN `json:"k"` 312 L strfmt.ISBN10 `json:"l"` 313 M strfmt.ISBN13 `json:"m"` 314 N strfmt.RGBColor `json:"n"` 315 O strfmt.SSN `json:"o"` 316 P strfmt.URI `json:"p"` 317 Q strfmt.UUID `json:"q"` 318 R strfmt.UUID3 `json:"r"` 319 S strfmt.UUID4 `json:"s"` 320 T strfmt.UUID5 `json:"t"` 321 U strfmt.MAC `json:"u"` 322 } 323 324 // A SimpleComplexModel is a struct with only other struct types 325 // 326 // It doesn't have slices or arrays etc but only complex types 327 // so also no primitives or string formatters 328 type SimpleComplexModel struct { 329 Top Something `json:"top"` 330 331 NotSel mods.NotSelected `json:"notSel"` 332 333 Emb struct { 334 CID int64 `json:"cid"` 335 Baz string `json:"baz"` 336 } `json:"emb"` 337 } 338 339 // Pointdexter is a struct with only pointers 340 type Pointdexter struct { 341 ID *int64 `json:"id"` 342 Name *string `json:"name"` 343 T *strfmt.UUID5 `json:"t"` 344 Top *Something `json:"top"` 345 346 NotSel *mods.NotSelected `json:"notSel"` 347 348 Emb *struct { 349 CID *int64 `json:"cid"` 350 Baz *string `json:"baz"` 351 } `json:"emb"` 352 } 353 354 // A SliceAndDice struct contains only slices 355 // 356 // the elements of the slices are structs, primitives or string formats 357 // there is also a pointer version of each property 358 type SliceAndDice struct { 359 IDs []int64 `json:"ids"` 360 Names []string `json:"names"` 361 UUIDs []strfmt.UUID `json:"uuids"` 362 Tops []Something `json:"tops"` 363 NotSels []mods.NotSelected `json:"notSels"` 364 Embs []struct { 365 CID []int64 `json:"cid"` 366 Baz []string `json:"baz"` 367 } `json:"embs"` 368 369 PtrIDs []*int64 `json:"ptrIds"` 370 PtrNames []*string `json:"ptrNames"` 371 PtrUUIDs []*strfmt.UUID `json:"ptrUuids"` 372 PtrTops []*Something `json:"ptrTops"` 373 PtrNotSels []*mods.NotSelected `json:"ptrNotSels"` 374 PtrEmbs []*struct { 375 PtrCID []*int64 `json:"ptrCid"` 376 PtrBaz []*string `json:"ptrBaz"` 377 } `json:"ptrEmbs"` 378 } 379 380 // A MapTastic struct contains only maps 381 // 382 // the values of the maps are structs, primitives or string formats 383 // there is also a pointer version of each property 384 type MapTastic struct { 385 IDs map[string]int64 `json:"ids"` 386 Names map[string]string `json:"names"` 387 UUIDs map[string]strfmt.UUID `json:"uuids"` 388 Tops map[string]Something `json:"tops"` 389 NotSels map[string]mods.NotSelected `json:"notSels"` 390 Embs map[string]struct { 391 CID map[string]int64 `json:"cid"` 392 Baz map[string]string `json:"baz"` 393 } `json:"embs"` 394 395 PtrIDs map[string]*int64 `json:"ptrIds"` 396 PtrNames map[string]*string `json:"ptrNames"` 397 PtrUUIDs map[string]*strfmt.UUID `json:"ptrUuids"` 398 PtrTops map[string]*Something `json:"ptrTops"` 399 PtrNotSels map[string]*mods.NotSelected `json:"ptrNotSels"` 400 PtrEmbs map[string]*struct { 401 PtrCID map[string]*int64 `json:"ptrCid"` 402 PtrBaz map[string]*string `json:"ptrBaz"` 403 } `json:"ptrEmbs"` 404 } 405 406 // An Interfaced struct contains objects with interface definitions 407 type Interfaced struct { 408 CustomData interface{} `json:"custom_data"` 409 } 410 411 // A BaseStruct is a struct that has subtypes. 412 // 413 // it should deserialize into one of the struct types that 414 // enlist for being implementations of this struct 415 // 416 // swagger:model animal 417 type BaseStruct struct { 418 // ID of this no model instance. 419 // ids in this application start at 11 and are smaller than 1000 420 // 421 // required: true 422 // minimum: > 10 423 // maximum: < 1000 424 ID int64 `json:"id"` 425 426 // Name of this no model instance 427 // 428 // min length: 4 429 // max length: 50 430 // pattern: [A-Za-z0-9-.]* 431 // required: true 432 Name string `json:"name"` 433 434 // StructType the type of this polymorphic model 435 // 436 // discriminator: true 437 StructType string `json:"jsonClass"` 438 } 439 440 /* TODO: implement this in the scanner 441 442 // A Lion is a struct that "subtypes" the BaseStruct 443 // 444 // it does so because it included the fields in the struct body 445 // The scanner assumes it will follow the rules and describes this type 446 // as discriminated in the swagger spec based on the discriminator value 447 // annotation. 448 // 449 // swagger:model lion 450 // swagger:discriminatorValue animal org.horrible.java.fqpn.TheLionDataObjectFactoryInstanceServiceImpl 451 type Lion struct { 452 // ID of this no model instance. 453 // ids in this application start at 11 and are smaller than 1000 454 // 455 // required: true 456 // minimum: > 10 457 // maximum: < 1000 458 ID int64 `json:"id"` 459 460 // Name of this no model instance 461 // 462 // min length: 4 463 // max length: 50 464 // pattern: [A-Za-z0-9-.]* 465 // required: true 466 Name string `json:"name"` 467 468 // StructType the type of this polymorphic model 469 StructType string `json:"jsonClass"` 470 471 // Leader is true when this is the leader of its group 472 // 473 // default value: false 474 Leader bool `json:"leader"` 475 } 476 */ 477 478 // A Giraffe is a struct that embeds BaseStruct 479 // 480 // the annotation is not necessary here because of inclusion 481 // of a discriminated type 482 // it infers the name of the x-class value from its context 483 // 484 // swagger:model giraffe 485 type Giraffe struct { 486 // swagger:allOf 487 BaseStruct 488 489 // NeckSize the size of the neck of this giraffe 490 NeckSize int64 `json:"neckSize"` 491 } 492 493 // A Gazelle is a struct is discriminated for BaseStruct. 494 // 495 // The struct includes the BaseStruct and that embedded value 496 // is annotated with the discriminator value annotation so it 497 // where it only requires 1 argument because it knows which 498 // discriminator type this belongs to 499 // 500 // swagger:model gazelle 501 type Gazelle struct { 502 // swagger:allOf a.b.c.d.E 503 BaseStruct 504 505 // The size of the horns 506 HornSize float32 `json:"hornSize"` 507 } 508 509 // Identifiable is an interface for things that have an ID 510 type Identifiable interface { 511 // ID of this no model instance. 512 // ids in this application start at 11 and are smaller than 1000 513 // 514 // required: true 515 // minimum: > 10 516 // maximum: < 1000 517 // swagger:name id 518 ID() int64 519 } 520 521 // WaterType is an interface describing a water type 522 // 523 // swagger:model water 524 type WaterType interface { 525 // swagger:name sweetWater 526 SweetWater() bool 527 // swagger:name saltWater 528 SaltWater() bool 529 } 530 531 // Fish represents a base type implemented as interface 532 // the nullary methods of this interface will be included as 533 // 534 // swagger:model fish 535 type Fish interface { 536 Identifiable // interfaces like this are included as if they were defined directly on this type 537 538 // embeds decorated with allOf are included as refs 539 540 // swagger:allOf 541 WaterType 542 543 // swagger:allOf 544 mods.ExtraInfo 545 546 mods.EmbeddedColor 547 548 Items(id, size int64) []string 549 550 // Name of this no model instance 551 // 552 // min length: 4 553 // max length: 50 554 // pattern: [A-Za-z0-9-.]* 555 // required: true 556 // swagger:name name 557 Name() string 558 559 // StructType the type of this polymorphic model 560 // Discriminator: true 561 // swagger:name jsonClass 562 StructType() string 563 } 564 565 // TeslaCar is a tesla car 566 // 567 // swagger:model 568 type TeslaCar interface { 569 // The model of tesla car 570 // 571 // discriminated: true 572 // swagger:name model 573 Model() string 574 575 // AutoPilot returns true when it supports autopilot 576 // swagger:name autoPilot 577 AutoPilot() bool 578 } 579 580 // The ModelS version of the tesla car 581 // 582 // swagger:model modelS 583 type ModelS struct { 584 // swagger:allOf com.tesla.models.ModelS 585 TeslaCar 586 // The edition of this Model S 587 Edition string `json:"edition"` 588 } 589 590 // The ModelX version of the tesla car 591 // 592 // swagger:model modelX 593 type ModelX struct { 594 // swagger:allOf com.tesla.models.ModelX 595 TeslaCar 596 // The number of doors on this Model X 597 Doors int `json:"doors"` 598 } 599 600 // The ModelA version of the tesla car 601 // 602 // swagger:model modelA 603 type ModelA struct { 604 Tesla TeslaCar 605 // The number of doors on this Model A 606 Doors int `json:"doors"` 607 } 608 609 // Cars is a collection of cars 610 // 611 // swagger:model cars 612 type Cars struct { 613 Cars []*TeslaCar `json:"cars"` 614 } 615 616 // JSONString has fields with ",string" JSON directives. 617 // 618 // swagger:model jsonString 619 type JSONString struct { 620 // Should be encoded as a string with string format "integer" 621 SomeInt int `json:"someInt,string"` 622 SomeInt8 int8 `json:"someInt8,string"` 623 SomeInt16 int16 `json:"someInt16,string"` 624 SomeInt32 int32 `json:"someInt32,string"` 625 SomeInt64 int64 `json:"someInt64,string"` 626 SomeUint uint `json:"someUint,string"` 627 SomeUint8 uint8 `json:"someUint8,string"` 628 SomeUint16 uint16 `json:"someUint16,string"` 629 SomeUint32 uint32 `json:"someUint32,string"` 630 SomeUint64 uint64 `json:"someUint64,string"` 631 632 // Should be encoded as a string with string format "double" 633 SomeFloat64 float64 `json:"someFloat64,string"` 634 635 // Should be encoded as a string with no format 636 SomeString string `json:"someString,string"` 637 638 // Should be encoded as a string with no format 639 SomeBool bool `json:"someBool,string"` 640 641 // The ",string" directive should be ignore before the type isn't scalar 642 SomethingElse Cars `json:"somethingElse,string"` 643 } 644 645 // IgnoredFields demostrates the use of swagger:ignore on struct fields. 646 // 647 // swagger:model ignoredFields 648 type IgnoredFields struct { 649 SomeIncludedField string `json:"someIncludedField"` 650 651 // swagger:ignore 652 SomeIgnoredField string `json:"someIgnoredField"` 653 654 // This swagger:ignore tag won't work - it needs to be in the field's doc 655 // block 656 SomeErroneouslyIncludedField string `json:"someErroneouslyIncludedField"` // swagger:ignore 657 }