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