github.com/go-swagger/go-swagger@v0.31.0/examples/external-types/restapi/embedded_spec.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package restapi
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"encoding/json"
    10  )
    11  
    12  var (
    13  	// SwaggerJSON embedded version of the swagger document used at generation time
    14  	SwaggerJSON json.RawMessage
    15  	// FlatSwaggerJSON embedded flattened version of the swagger document used at generation time
    16  	FlatSwaggerJSON json.RawMessage
    17  )
    18  
    19  func init() {
    20  	SwaggerJSON = json.RawMessage([]byte(`{
    21    "swagger": "2.0",
    22    "info": {
    23      "description": "This sample specification exercises external types, with both x-go-type in definitions and inlined.\n\nIt demonstrates how to use the x-go-type extension to plug external type definitions in the generated code,\nfor models (e.g. for properties, arrays or maps) or operations.\n\nNotice that x-go-type works for schemas and is not supported for simple swagger types,\nused for response headers and query \u0026 path parameters.\n",
    24      "title": "external types imports: external anonymous types",
    25      "version": "1.0"
    26    },
    27    "paths": {
    28      "/stream": {
    29        "get": {
    30          "responses": {
    31            "default": {
    32              "description": "Uses an external definition for an interface (e.g. io.Reader)\n\nNo validation is expected on binary format.\n",
    33              "schema": {
    34                "$ref": "#/definitions/MyReader"
    35              }
    36            }
    37          }
    38        }
    39      },
    40      "/test": {
    41        "get": {
    42          "responses": {
    43            "default": {
    44              "description": "A reference to a type already defined in the models package\n(defaults to \u003c\u003ctarget\u003e/models, defined by CLI flag --model-package).\nThe response payload is defined as: *models.Zzz\n",
    45              "schema": {
    46                "$ref": "#/definitions/Zzz"
    47              }
    48            }
    49          }
    50        },
    51        "put": {
    52          "parameters": [
    53            {
    54              "description": "A reference to a type defined in the \"fred\" package, aliased\nas \"alternate\".\n\nMyAlternate alternate.MyAlternateType\n",
    55              "name": "myAlternate",
    56              "in": "body",
    57              "required": true,
    58              "schema": {
    59                "$ref": "#/definitions/MyCustom"
    60              }
    61            }
    62          ],
    63          "responses": {
    64            "default": {
    65              "description": "A map of an aliased external package. Now the alias is \"custom\".\nThis response is defined as: map[string]custom.MyAlternateString\n",
    66              "schema": {
    67                "type": "object",
    68                "additionalProperties": {
    69                  "description": "This uses the external type from an inline definition, without $ref\n",
    70                  "type": "object",
    71                  "x-go-type": {
    72                    "import": {
    73                      "alias": "custom",
    74                      "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
    75                    },
    76                    "type": "MyAlternateString"
    77                  }
    78                }
    79              }
    80            }
    81          }
    82        },
    83        "post": {
    84          "parameters": [
    85            {
    86              "description": "Defines a parameter as an array of external types.\nThe body parameter is defined as []custom.MyAlternateString\n\nNo definition is generated in models.\n",
    87              "name": "customizedStrings",
    88              "in": "body",
    89              "schema": {
    90                "type": "array",
    91                "items": {
    92                  "type": "string",
    93                  "x-go-type": {
    94                    "import": {
    95                      "alias": "custom",
    96                      "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
    97                    },
    98                    "type": "MyAlternateString"
    99                  }
   100                }
   101              }
   102            }
   103          ],
   104          "responses": {
   105            "default": {
   106              "description": "An inlined reference to an aliased external package.\nThe response is defined as map[string][]map[string]custom.MyAlternateString\n\nNo definition is generated in models.\n",
   107              "schema": {
   108                "type": "object",
   109                "additionalProperties": {
   110                  "type": "array",
   111                  "items": {
   112                    "type": "object",
   113                    "additionalProperties": {
   114                      "x-go-type": {
   115                        "import": {
   116                          "alias": "custom",
   117                          "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   118                        },
   119                        "type": "MyAlternateString"
   120                      }
   121                    }
   122                  }
   123                }
   124              }
   125            }
   126          }
   127        }
   128      }
   129    },
   130    "definitions": {
   131      "ArrayWithNoValidate": {
   132        "description": "A slice of NoValidateExternal external types.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `http.Request` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n",
   133        "type": "array",
   134        "maxItems": 12,
   135        "uniqueItems": true,
   136        "items": {
   137          "$ref": "#/definitions/NoValidateExternal"
   138        }
   139      },
   140      "EmbeddedTime": {
   141        "description": "\nThis type demonstrates how we can embed an external type and wraps the validation.\n\nThis is especially useful if you want to reuse some types from the standard library,\nsuch as ` + "`" + `time.Time` + "`" + ` or ` + "`" + `json.RawMessage` + "`" + `.\n",
   142        "x-go-type": {
   143          "embedded": true,
   144          "import": {
   145            "package": "time"
   146          },
   147          "type": "Time"
   148        }
   149      },
   150      "MapOfPrimitives": {
   151        "description": "A map of NoValidatePrimitive external types.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `time.Duration` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n",
   152        "type": "object",
   153        "additionalProperties": {
   154          "$ref": "#/definitions/NoValidatePrimitive"
   155        }
   156      },
   157      "MapWithNoValidate": {
   158        "description": "A map of NoValidateExternal external types.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `http.Request` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n",
   159        "type": "object",
   160        "additionalProperties": {
   161          "$ref": "#/definitions/NoValidateExternal"
   162        }
   163      },
   164      "MyCustom": {
   165        "description": "The generated code expects this type to be already defined in the \"fred\" package.\nAn alias is used by the generated code. Aliases are convenient to avoid\nconflicts with other imports or variables in the generated code.\n",
   166        "type": "object",
   167        "x-go-type": {
   168          "import": {
   169            "alias": "alternate",
   170            "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   171          },
   172          "type": "MyAlternateType"
   173        }
   174      },
   175      "MyCustomArray": {
   176        "description": "This generate an array type in models, based on the external type.\n\n[]alternate.MyAlternateType\n\nThe validation method of the external type is called by the generated array.\n",
   177        "type": "array",
   178        "items": {
   179          "type": "object",
   180          "x-go-type": {
   181            "import": {
   182              "alias": "alternate",
   183              "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   184            },
   185            "type": "MyAlternateType"
   186          }
   187        }
   188      },
   189      "MyCustomArrayNullable": {
   190        "description": "This generate an array type in models, based on the external type.\nNotice the impact of the nullable hint (equivalent to x-nullable at the type level), to produce a slice of pointers.\n\n[]*alternate.MyAlternateType\n",
   191        "type": "array",
   192        "items": {
   193          "type": "object",
   194          "x-go-type": {
   195            "hints": {
   196              "nullable": true
   197            },
   198            "import": {
   199              "alias": "alternate",
   200              "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   201            },
   202            "type": "MyAlternateType"
   203          }
   204        }
   205      },
   206      "MyCustomMap": {
   207        "description": "This generate a map type in models, based on the external type.\n\nMyCustomMap map[string]map[string]alternate.MyAlternateType\n\nThe validation method of the external type is called by the generated map.\n",
   208        "type": "object",
   209        "additionalProperties": {
   210          "type": "object",
   211          "additionalProperties": {
   212            "type": "object",
   213            "x-go-type": {
   214              "import": {
   215                "alias": "alternate",
   216                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   217              },
   218              "type": "MyAlternateType"
   219            }
   220          }
   221        }
   222      },
   223      "MyCustomMapNullable": {
   224        "description": "This generate a map type in models, based on the external type.\nNotice the impact of the x-nullable directive, to produce a map of pointers.\n\nMapNullable map[string]map[string]*alternate.MyAlternateType\n",
   225        "type": "object",
   226        "additionalProperties": {
   227          "type": "object",
   228          "additionalProperties": {
   229            "type": "object",
   230            "x-go-type": {
   231              "import": {
   232                "alias": "alternate",
   233                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   234              },
   235              "type": "MyAlternateType"
   236            },
   237            "x-nullable": true
   238          }
   239        }
   240      },
   241      "MyExtCollection": {
   242        "description": "This type demonstrates the import generation with name mangling\n",
   243        "type": "array",
   244        "items": {
   245          "$ref": "#/definitions/MyExtStruct"
   246        }
   247      },
   248      "MyExtStruct": {
   249        "description": "This type is located in a package which requires name mangling.\n",
   250        "x-go-type": {
   251          "import": {
   252            "package": "github.com/go-swagger/go-swagger/examples/external-types/go-ext"
   253          },
   254          "type": "MyExtType"
   255        }
   256      },
   257      "MyInterface": {
   258        "description": "This is an external type replacing the interface{} type normally generated.\n\nNo validation is called on such a type.\n\nThis demonstrates how to use hints in x-go-type: by default, the generator\nassumes a struct with some Validate method.\n\nBy providing the \"interface\" hint, validation is disabled. Notice that we don't\ngenerate pointers on interfaces.\n\nIf no hint is provided, the generate code won't compile is the MyAlternateInterface\ndoes not provide a Validate method.\n",
   259        "x-go-type": {
   260          "hints": {
   261            "kind": "interface"
   262          },
   263          "import": {
   264            "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   265          },
   266          "type": "MyAlternateInterface"
   267        }
   268      },
   269      "MyInterfaceObject": {
   270        "description": "This object demonstrates several ways to refer to an external interface.\n\nThe generated code behaves as it is an interface{}: no pointers are generated, and no valication\nis required.\n",
   271        "type": "object",
   272        "required": [
   273          "iface2",
   274          "iface3"
   275        ],
   276        "properties": {
   277          "iface1": {
   278            "$ref": "#/definitions/MyInterface"
   279          },
   280          "iface2": {
   281            "description": "Demonstrates the impact of the \"interface\" hint: no validation is called on iface2,\nand no pointer is generated in spite of the \"required\" directive.\n\nThe generated object validation checks for the \"required\" directive.\n\nWithout the hint, the generator assumes a Validatable object, with pointer, which may\nnot build, depending on how the external type is defined.\n",
   282            "x-go-type": {
   283              "hints": {
   284                "kind": "interface"
   285              },
   286              "import": {
   287                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   288              },
   289              "type": "MyAlternateInterface"
   290            }
   291          },
   292          "iface3": {
   293            "description": "Demonstrates the impact of the \"noValidation\" hint.\n\nNotice how we avoid the generation of a pointer on the required json.RawMessage (which is a []byte)\nwith the \"nullable\" hint.\n\nNotice that the \"json\" package is automatically deconflicted from other standard imports with a distinct alias.\n",
   294            "x-go-type": {
   295              "hints": {
   296                "noValidation": true,
   297                "nullable": false
   298              },
   299              "import": {
   300                "package": "encoding/json"
   301              },
   302              "type": "RawMessage"
   303            }
   304          }
   305        }
   306      },
   307      "MyReader": {
   308        "description": "This is an external type replacing the io.Reader type normally generated.\n\nNo validation is called on such a type.\n",
   309        "type": "string",
   310        "format": "binary",
   311        "x-go-type": {
   312          "type": "MyStreamer"
   313        }
   314      },
   315      "MyReaderObject": {
   316        "description": "This object demonstrates several ways to refer to an external interface (here assumed akin to io.Reader).\nMarshalBinary() methods are generated. No validation is expected on binary format.",
   317        "type": "object",
   318        "properties": {
   319          "reader1": {
   320            "$ref": "#/definitions/MyReader"
   321          },
   322          "reader2": {
   323            "description": "In line definition of the external type.\n\nNotice that we have provided some information in the spec, so the generator\ncan infer we want it to be understood as an io.Reader, with no validation.\n",
   324            "type": "string",
   325            "format": "binary",
   326            "x-go-type": {
   327              "import": {
   328                "alias": "alternate",
   329                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   330              },
   331              "type": "MyAlternateStreamer"
   332            }
   333          },
   334          "reader3": {
   335            "description": "In line definition of the external type.\n\nNotice that we have provided some information in the spec, as a hint in the extension\nrather than in the type definition.\n\nSo this will be documented as an object, but the generated code knows this is a stream.\n",
   336            "x-go-type": {
   337              "hints": {
   338                "kind": "stream"
   339              },
   340              "import": {
   341                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   342              },
   343              "type": "MyAlternateStreamer"
   344            }
   345          }
   346        }
   347      },
   348      "MyTuple": {
   349        "description": "Demonstrates references to some external type in the context of a tuple.\n\nNotice that \"additionalItems\" is not a construct that pass swagger validation,\nbut is supported by go-swagger.\n",
   350        "type": "array",
   351        "items": [
   352          {
   353            "$ref": "#/definitions/MyType"
   354          },
   355          {
   356            "description": "Second element of the tuple, defined as follows.\n\nP1 *fred.MyAlternateType ` + "`" + `json:\"-\"` + "`" + ` // custom serializer\n",
   357            "type": "object",
   358            "x-go-type": {
   359              "import": {
   360                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   361              },
   362              "type": "MyAlternateType"
   363            }
   364          }
   365        ],
   366        "additionalItems": {
   367          "description": "Additional items to a tuple, from an external type.\nThis defines the following field in the tuple\n\nMyTupleItems []map[string]fred.MyAlternateType\n",
   368          "type": "object",
   369          "additionalProperties": {
   370            "x-go-type": {
   371              "import": {
   372                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   373              },
   374              "type": "MyAlternateType"
   375            }
   376          }
   377        }
   378      },
   379      "MyType": {
   380        "description": "The generated code expects this type to be already defined in the models package\n(default location when no package is specified).\n",
   381        "type": "object",
   382        "x-go-type": {
   383          "type": "MyType"
   384        }
   385      },
   386      "NoValidateExternal": {
   387        "description": "\nThis type demonstrates how we can disable validation for an external type.\n\nThis is useful if you want to reuse some types from the standard library and don't\nwant to resort to an embedded type.\n",
   388        "type": "object",
   389        "x-go-type": {
   390          "hints": {
   391            "noValidation": true
   392          },
   393          "import": {
   394            "package": "net/http"
   395          },
   396          "type": "Request"
   397        }
   398      },
   399      "NoValidatePrimitive": {
   400        "description": "\nThis type demonstrates how we can disable validation for an external primitive type.\n",
   401        "type": "integer",
   402        "x-go-type": {
   403          "hints": {
   404            "noValidation": true
   405          },
   406          "import": {
   407            "package": "time"
   408          },
   409          "type": "Duration"
   410        }
   411      },
   412      "ObjectWithNoValidate": {
   413        "description": "A reference to the NoValidateExternal external type.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `http.Request` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n",
   414        "type": "object",
   415        "required": [
   416          "myMandatoryRequest"
   417        ],
   418        "properties": {
   419          "myMandatoryRequest": {
   420            "$ref": "#/definitions/NoValidateExternal"
   421          },
   422          "myRequest": {
   423            "$ref": "#/definitions/NoValidateExternal"
   424          }
   425        }
   426      },
   427      "TupleWithNoValidate": {
   428        "description": "A tuple of NoValidateExternal external types.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `http.Request` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n\nNotice that \"additionalItems\" is not a construct that pass swagger validation,\nbut is supported by go-swagger.\n",
   429        "type": "array",
   430        "items": [
   431          {
   432            "$ref": "#/definitions/NoValidateExternal"
   433          },
   434          {
   435            "$ref": "#/definitions/NoValidateExternal"
   436          }
   437        ],
   438        "additionalItems": {
   439          "$ref": "#/definitions/NoValidateExternal"
   440        }
   441      },
   442      "Zzz": {
   443        "description": "This demonstrates variations in generated code, depending on how properties are declared.\n\nSome properties are directly based on some external type and some other define collections (slices, maps)\nof these external types.\n\nNotice the use of pointers for required properties, but not for slices or maps.\n\nIn addition, it demonstrates how pointer generation may be controlled with the nullable hint or the x-nullable extension.\n\ntype Zzz struct {\n\tBeta []MyOtherType ` + "`" + `json:\"beta\"` + "`" + `\n\tDelta MyInteger ` + "`" + `json:\"delta,omitempty\"` + "`" + `\n\tEpsilon []custom.MyAlternateType ` + "`" + `json:\"epsilon\"` + "`" + `\n\tGamma fred.MyAlternateInteger ` + "`" + `json:\"gamma,omitempty\"` + "`" + `\n\tMeta MyType ` + "`" + `json:\"meta,omitempty\"` + "`" + `\n\n\tNullableBeta []*MyOtherType ` + "`" + `json:\"nullableBeta\"` + "`" + `\n\tNullableDelta *MyInteger ` + "`" + `json:\"nullableDelta,omitempty\"` + "`" + `\n\tNullableEpsilon []*custom.MyAlternateType ` + "`" + `json:\"nullableEpsilon\"` + "`" + `\n\tNullableGamma *fred.MyAlternateInteger ` + "`" + `json:\"nullableGamma,omitempty\"` + "`" + `\n\tNullableMeta MyType ` + "`" + `json:\"nullableMeta,omitempty\"` + "`" + `\n\n\tReqBeta []MyOtherType ` + "`" + `json:\"reqBeta\"` + "`" + `\n\tReqDelta *MyInteger ` + "`" + `json:\"reqDelta\"` + "`" + `\n\tReqEpsilon []custom.MyAlternateType ` + "`" + `json:\"reqEpsilon\"` + "`" + `\n\tReqGamma *fred.MyAlternateInteger ` + "`" + `json:\"reqGamma\"` + "`" + `\n\tReqMeta *MyType ` + "`" + `json:\"reqMeta\"` + "`" + `\n}\n",
   444        "type": "object",
   445        "required": [
   446          "reqBeta",
   447          "reqDelta",
   448          "reqGamma",
   449          "reqEpsilon",
   450          "reqMeta"
   451        ],
   452        "properties": {
   453          "beta": {
   454            "description": "This property defines an array of external types (in the same package).\n\n[]MyOtherType\n\nThe maxItems validation is generated and the external validation is called for every item.\n",
   455            "type": "array",
   456            "maxItems": 15,
   457            "items": {
   458              "type": "object",
   459              "x-go-type": {
   460                "type": "MyOtherType"
   461              }
   462            }
   463          },
   464          "delta": {
   465            "description": "A type is provided (integer), and the implementation is an external type in the same package.\n\nThe maximum validation remains documentary and is ignored by the generated code.\n",
   466            "type": "integer",
   467            "maximum": 15,
   468            "x-go-type": {
   469              "type": "MyInteger"
   470            }
   471          },
   472          "epsilon": {
   473            "type": "array",
   474            "items": {
   475              "type": "object",
   476              "x-go-type": {
   477                "import": {
   478                  "alias": "custom",
   479                  "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   480                },
   481                "type": "MyAlternateType"
   482              }
   483            }
   484          },
   485          "gamma": {
   486            "description": "Property defined as an external type from package \"fred\"\n",
   487            "x-go-type": {
   488              "import": {
   489                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   490              },
   491              "type": "MyAlternateInteger"
   492            }
   493          },
   494          "meta": {
   495            "$ref": "#/definitions/MyType"
   496          },
   497          "nullableBeta": {
   498            "description": "This property defines an array of external types (in the same package).\n\n[]MyOtherType\n\nThe maxItems validation is generated and the external validation is called for every item.\n",
   499            "type": "array",
   500            "maxItems": 15,
   501            "items": {
   502              "type": "object",
   503              "x-go-type": {
   504                "hints": {
   505                  "nullable": true
   506                },
   507                "type": "MyOtherType"
   508              }
   509            }
   510          },
   511          "nullableDelta": {
   512            "description": "A type is provided (integer), and the implementation is an external type in the same package.\n\nThe maximum validation remains documentary and is ignored by the generated code.\n\nNullableDelta *MyInteger\n",
   513            "type": "integer",
   514            "maximum": 15,
   515            "x-go-type": {
   516              "type": "MyInteger"
   517            },
   518            "x-nullable": true
   519          },
   520          "nullableEpsilon": {
   521            "description": "In this example, items are made nullable.\n\nNullableEpsilon []*custom.MyAlternateType ` + "`" + `json:\"nullableEpsilon\"` + "`" + `\n",
   522            "type": "array",
   523            "items": {
   524              "type": "object",
   525              "x-go-type": {
   526                "import": {
   527                  "alias": "custom",
   528                  "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   529                },
   530                "type": "MyAlternateType"
   531              },
   532              "x-nullable": true
   533            }
   534          },
   535          "nullableGamma": {
   536            "description": "Property defined as an external type from package \"fred\", with a nullable hint for the\nexternal type.\n\nNullableGamma *fred.MyAlternateInteger ` + "`" + `json:\"nullableGamma,omitempty\"` + "`" + `\n",
   537            "x-go-type": {
   538              "hints": {
   539                "nullable": true
   540              },
   541              "import": {
   542                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   543              },
   544              "type": "MyAlternateInteger"
   545            }
   546          },
   547          "nullableMeta": {
   548            "x-nullable": true,
   549            "$ref": "#/definitions/MyType"
   550          },
   551          "reqBeta": {
   552            "type": "array",
   553            "items": {
   554              "type": "object",
   555              "x-go-type": {
   556                "type": "MyOtherType"
   557              }
   558            }
   559          },
   560          "reqDelta": {
   561            "type": "integer",
   562            "x-go-type": {
   563              "type": "MyInteger"
   564            }
   565          },
   566          "reqEpsilon": {
   567            "type": "array",
   568            "items": {
   569              "type": "object",
   570              "x-go-type": {
   571                "import": {
   572                  "alias": "custom",
   573                  "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   574                },
   575                "type": "MyAlternateType"
   576              }
   577            }
   578          },
   579          "reqGamma": {
   580            "x-go-type": {
   581              "import": {
   582                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   583              },
   584              "type": "MyAlternateInteger"
   585            }
   586          },
   587          "reqMeta": {
   588            "$ref": "#/definitions/MyType"
   589          }
   590        }
   591      }
   592    }
   593  }`))
   594  	FlatSwaggerJSON = json.RawMessage([]byte(`{
   595    "swagger": "2.0",
   596    "info": {
   597      "description": "This sample specification exercises external types, with both x-go-type in definitions and inlined.\n\nIt demonstrates how to use the x-go-type extension to plug external type definitions in the generated code,\nfor models (e.g. for properties, arrays or maps) or operations.\n\nNotice that x-go-type works for schemas and is not supported for simple swagger types,\nused for response headers and query \u0026 path parameters.\n",
   598      "title": "external types imports: external anonymous types",
   599      "version": "1.0"
   600    },
   601    "paths": {
   602      "/stream": {
   603        "get": {
   604          "responses": {
   605            "default": {
   606              "description": "Uses an external definition for an interface (e.g. io.Reader)\n\nNo validation is expected on binary format.\n",
   607              "schema": {
   608                "$ref": "#/definitions/MyReader"
   609              }
   610            }
   611          }
   612        }
   613      },
   614      "/test": {
   615        "get": {
   616          "responses": {
   617            "default": {
   618              "description": "A reference to a type already defined in the models package\n(defaults to \u003c\u003ctarget\u003e/models, defined by CLI flag --model-package).\nThe response payload is defined as: *models.Zzz\n",
   619              "schema": {
   620                "$ref": "#/definitions/Zzz"
   621              }
   622            }
   623          }
   624        },
   625        "put": {
   626          "parameters": [
   627            {
   628              "description": "A reference to a type defined in the \"fred\" package, aliased\nas \"alternate\".\n\nMyAlternate alternate.MyAlternateType\n",
   629              "name": "myAlternate",
   630              "in": "body",
   631              "required": true,
   632              "schema": {
   633                "$ref": "#/definitions/MyCustom"
   634              }
   635            }
   636          ],
   637          "responses": {
   638            "default": {
   639              "description": "A map of an aliased external package. Now the alias is \"custom\".\nThis response is defined as: map[string]custom.MyAlternateString\n",
   640              "schema": {
   641                "type": "object",
   642                "additionalProperties": {
   643                  "description": "This uses the external type from an inline definition, without $ref\n",
   644                  "type": "object",
   645                  "x-go-type": {
   646                    "import": {
   647                      "alias": "custom",
   648                      "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   649                    },
   650                    "type": "MyAlternateString"
   651                  }
   652                }
   653              }
   654            }
   655          }
   656        },
   657        "post": {
   658          "parameters": [
   659            {
   660              "description": "Defines a parameter as an array of external types.\nThe body parameter is defined as []custom.MyAlternateString\n\nNo definition is generated in models.\n",
   661              "name": "customizedStrings",
   662              "in": "body",
   663              "schema": {
   664                "type": "array",
   665                "items": {
   666                  "type": "string",
   667                  "x-go-type": {
   668                    "import": {
   669                      "alias": "custom",
   670                      "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   671                    },
   672                    "type": "MyAlternateString"
   673                  }
   674                }
   675              }
   676            }
   677          ],
   678          "responses": {
   679            "default": {
   680              "description": "An inlined reference to an aliased external package.\nThe response is defined as map[string][]map[string]custom.MyAlternateString\n\nNo definition is generated in models.\n",
   681              "schema": {
   682                "type": "object",
   683                "additionalProperties": {
   684                  "type": "array",
   685                  "items": {
   686                    "type": "object",
   687                    "additionalProperties": {
   688                      "x-go-type": {
   689                        "import": {
   690                          "alias": "custom",
   691                          "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   692                        },
   693                        "type": "MyAlternateString"
   694                      }
   695                    }
   696                  }
   697                }
   698              }
   699            }
   700          }
   701        }
   702      }
   703    },
   704    "definitions": {
   705      "ArrayWithNoValidate": {
   706        "description": "A slice of NoValidateExternal external types.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `http.Request` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n",
   707        "type": "array",
   708        "maxItems": 12,
   709        "uniqueItems": true,
   710        "items": {
   711          "$ref": "#/definitions/NoValidateExternal"
   712        }
   713      },
   714      "EmbeddedTime": {
   715        "description": "\nThis type demonstrates how we can embed an external type and wraps the validation.\n\nThis is especially useful if you want to reuse some types from the standard library,\nsuch as ` + "`" + `time.Time` + "`" + ` or ` + "`" + `json.RawMessage` + "`" + `.\n",
   716        "x-go-type": {
   717          "embedded": true,
   718          "import": {
   719            "package": "time"
   720          },
   721          "type": "Time"
   722        }
   723      },
   724      "MapOfPrimitives": {
   725        "description": "A map of NoValidatePrimitive external types.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `time.Duration` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n",
   726        "type": "object",
   727        "additionalProperties": {
   728          "$ref": "#/definitions/NoValidatePrimitive"
   729        }
   730      },
   731      "MapWithNoValidate": {
   732        "description": "A map of NoValidateExternal external types.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `http.Request` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n",
   733        "type": "object",
   734        "additionalProperties": {
   735          "$ref": "#/definitions/NoValidateExternal"
   736        }
   737      },
   738      "MyCustom": {
   739        "description": "The generated code expects this type to be already defined in the \"fred\" package.\nAn alias is used by the generated code. Aliases are convenient to avoid\nconflicts with other imports or variables in the generated code.\n",
   740        "type": "object",
   741        "x-go-type": {
   742          "import": {
   743            "alias": "alternate",
   744            "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   745          },
   746          "type": "MyAlternateType"
   747        }
   748      },
   749      "MyCustomArray": {
   750        "description": "This generate an array type in models, based on the external type.\n\n[]alternate.MyAlternateType\n\nThe validation method of the external type is called by the generated array.\n",
   751        "type": "array",
   752        "items": {
   753          "type": "object",
   754          "x-go-type": {
   755            "import": {
   756              "alias": "alternate",
   757              "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   758            },
   759            "type": "MyAlternateType"
   760          }
   761        }
   762      },
   763      "MyCustomArrayNullable": {
   764        "description": "This generate an array type in models, based on the external type.\nNotice the impact of the nullable hint (equivalent to x-nullable at the type level), to produce a slice of pointers.\n\n[]*alternate.MyAlternateType\n",
   765        "type": "array",
   766        "items": {
   767          "type": "object",
   768          "x-go-type": {
   769            "hints": {
   770              "nullable": true
   771            },
   772            "import": {
   773              "alias": "alternate",
   774              "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   775            },
   776            "type": "MyAlternateType"
   777          }
   778        }
   779      },
   780      "MyCustomMap": {
   781        "description": "This generate a map type in models, based on the external type.\n\nMyCustomMap map[string]map[string]alternate.MyAlternateType\n\nThe validation method of the external type is called by the generated map.\n",
   782        "type": "object",
   783        "additionalProperties": {
   784          "type": "object",
   785          "additionalProperties": {
   786            "type": "object",
   787            "x-go-type": {
   788              "import": {
   789                "alias": "alternate",
   790                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   791              },
   792              "type": "MyAlternateType"
   793            }
   794          }
   795        }
   796      },
   797      "MyCustomMapNullable": {
   798        "description": "This generate a map type in models, based on the external type.\nNotice the impact of the x-nullable directive, to produce a map of pointers.\n\nMapNullable map[string]map[string]*alternate.MyAlternateType\n",
   799        "type": "object",
   800        "additionalProperties": {
   801          "type": "object",
   802          "additionalProperties": {
   803            "type": "object",
   804            "x-go-type": {
   805              "import": {
   806                "alias": "alternate",
   807                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   808              },
   809              "type": "MyAlternateType"
   810            },
   811            "x-nullable": true
   812          }
   813        }
   814      },
   815      "MyExtCollection": {
   816        "description": "This type demonstrates the import generation with name mangling\n",
   817        "type": "array",
   818        "items": {
   819          "$ref": "#/definitions/MyExtStruct"
   820        }
   821      },
   822      "MyExtStruct": {
   823        "description": "This type is located in a package which requires name mangling.\n",
   824        "x-go-type": {
   825          "import": {
   826            "package": "github.com/go-swagger/go-swagger/examples/external-types/go-ext"
   827          },
   828          "type": "MyExtType"
   829        }
   830      },
   831      "MyInterface": {
   832        "description": "This is an external type replacing the interface{} type normally generated.\n\nNo validation is called on such a type.\n\nThis demonstrates how to use hints in x-go-type: by default, the generator\nassumes a struct with some Validate method.\n\nBy providing the \"interface\" hint, validation is disabled. Notice that we don't\ngenerate pointers on interfaces.\n\nIf no hint is provided, the generate code won't compile is the MyAlternateInterface\ndoes not provide a Validate method.\n",
   833        "x-go-type": {
   834          "hints": {
   835            "kind": "interface"
   836          },
   837          "import": {
   838            "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   839          },
   840          "type": "MyAlternateInterface"
   841        }
   842      },
   843      "MyInterfaceObject": {
   844        "description": "This object demonstrates several ways to refer to an external interface.\n\nThe generated code behaves as it is an interface{}: no pointers are generated, and no valication\nis required.\n",
   845        "type": "object",
   846        "required": [
   847          "iface2",
   848          "iface3"
   849        ],
   850        "properties": {
   851          "iface1": {
   852            "$ref": "#/definitions/MyInterface"
   853          },
   854          "iface2": {
   855            "description": "Demonstrates the impact of the \"interface\" hint: no validation is called on iface2,\nand no pointer is generated in spite of the \"required\" directive.\n\nThe generated object validation checks for the \"required\" directive.\n\nWithout the hint, the generator assumes a Validatable object, with pointer, which may\nnot build, depending on how the external type is defined.\n",
   856            "x-go-type": {
   857              "hints": {
   858                "kind": "interface"
   859              },
   860              "import": {
   861                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   862              },
   863              "type": "MyAlternateInterface"
   864            }
   865          },
   866          "iface3": {
   867            "description": "Demonstrates the impact of the \"noValidation\" hint.\n\nNotice how we avoid the generation of a pointer on the required json.RawMessage (which is a []byte)\nwith the \"nullable\" hint.\n\nNotice that the \"json\" package is automatically deconflicted from other standard imports with a distinct alias.\n",
   868            "x-go-type": {
   869              "hints": {
   870                "noValidation": true,
   871                "nullable": false
   872              },
   873              "import": {
   874                "package": "encoding/json"
   875              },
   876              "type": "RawMessage"
   877            }
   878          }
   879        }
   880      },
   881      "MyReader": {
   882        "description": "This is an external type replacing the io.Reader type normally generated.\n\nNo validation is called on such a type.\n",
   883        "type": "string",
   884        "format": "binary",
   885        "x-go-type": {
   886          "type": "MyStreamer"
   887        }
   888      },
   889      "MyReaderObject": {
   890        "description": "This object demonstrates several ways to refer to an external interface (here assumed akin to io.Reader).\nMarshalBinary() methods are generated. No validation is expected on binary format.",
   891        "type": "object",
   892        "properties": {
   893          "reader1": {
   894            "$ref": "#/definitions/MyReader"
   895          },
   896          "reader2": {
   897            "description": "In line definition of the external type.\n\nNotice that we have provided some information in the spec, so the generator\ncan infer we want it to be understood as an io.Reader, with no validation.\n",
   898            "type": "string",
   899            "format": "binary",
   900            "x-go-type": {
   901              "import": {
   902                "alias": "alternate",
   903                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   904              },
   905              "type": "MyAlternateStreamer"
   906            }
   907          },
   908          "reader3": {
   909            "description": "In line definition of the external type.\n\nNotice that we have provided some information in the spec, as a hint in the extension\nrather than in the type definition.\n\nSo this will be documented as an object, but the generated code knows this is a stream.\n",
   910            "x-go-type": {
   911              "hints": {
   912                "kind": "stream"
   913              },
   914              "import": {
   915                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   916              },
   917              "type": "MyAlternateStreamer"
   918            }
   919          }
   920        }
   921      },
   922      "MyTuple": {
   923        "description": "Demonstrates references to some external type in the context of a tuple.\n\nNotice that \"additionalItems\" is not a construct that pass swagger validation,\nbut is supported by go-swagger.\n",
   924        "type": "array",
   925        "items": [
   926          {
   927            "$ref": "#/definitions/MyType"
   928          },
   929          {
   930            "description": "Second element of the tuple, defined as follows.\n\nP1 *fred.MyAlternateType ` + "`" + `json:\"-\"` + "`" + ` // custom serializer\n",
   931            "type": "object",
   932            "x-go-type": {
   933              "import": {
   934                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   935              },
   936              "type": "MyAlternateType"
   937            }
   938          }
   939        ],
   940        "additionalItems": {
   941          "description": "Additional items to a tuple, from an external type.\nThis defines the following field in the tuple\n\nMyTupleItems []map[string]fred.MyAlternateType\n",
   942          "type": "object",
   943          "additionalProperties": {
   944            "x-go-type": {
   945              "import": {
   946                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
   947              },
   948              "type": "MyAlternateType"
   949            }
   950          }
   951        }
   952      },
   953      "MyType": {
   954        "description": "The generated code expects this type to be already defined in the models package\n(default location when no package is specified).\n",
   955        "type": "object",
   956        "x-go-type": {
   957          "type": "MyType"
   958        }
   959      },
   960      "NoValidateExternal": {
   961        "description": "\nThis type demonstrates how we can disable validation for an external type.\n\nThis is useful if you want to reuse some types from the standard library and don't\nwant to resort to an embedded type.\n",
   962        "type": "object",
   963        "x-go-type": {
   964          "hints": {
   965            "noValidation": true
   966          },
   967          "import": {
   968            "package": "net/http"
   969          },
   970          "type": "Request"
   971        }
   972      },
   973      "NoValidatePrimitive": {
   974        "description": "\nThis type demonstrates how we can disable validation for an external primitive type.\n",
   975        "type": "integer",
   976        "x-go-type": {
   977          "hints": {
   978            "noValidation": true
   979          },
   980          "import": {
   981            "package": "time"
   982          },
   983          "type": "Duration"
   984        }
   985      },
   986      "ObjectWithNoValidate": {
   987        "description": "A reference to the NoValidateExternal external type.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `http.Request` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n",
   988        "type": "object",
   989        "required": [
   990          "myMandatoryRequest"
   991        ],
   992        "properties": {
   993          "myMandatoryRequest": {
   994            "$ref": "#/definitions/NoValidateExternal"
   995          },
   996          "myRequest": {
   997            "$ref": "#/definitions/NoValidateExternal"
   998          }
   999        }
  1000      },
  1001      "TupleWithNoValidate": {
  1002        "description": "A tuple of NoValidateExternal external types.\n\nIf the \"noValidation\" hint is omitted in the definition above, this code won't build because ` + "`" + `http.Request` + "`" + ` has no ` + "`" + `Validate` + "`" + ` method.\n\nNotice that \"additionalItems\" is not a construct that pass swagger validation,\nbut is supported by go-swagger.\n",
  1003        "type": "array",
  1004        "items": [
  1005          {
  1006            "$ref": "#/definitions/NoValidateExternal"
  1007          },
  1008          {
  1009            "$ref": "#/definitions/NoValidateExternal"
  1010          }
  1011        ],
  1012        "additionalItems": {
  1013          "$ref": "#/definitions/NoValidateExternal"
  1014        }
  1015      },
  1016      "Zzz": {
  1017        "description": "This demonstrates variations in generated code, depending on how properties are declared.\n\nSome properties are directly based on some external type and some other define collections (slices, maps)\nof these external types.\n\nNotice the use of pointers for required properties, but not for slices or maps.\n\nIn addition, it demonstrates how pointer generation may be controlled with the nullable hint or the x-nullable extension.\n\ntype Zzz struct {\n\tBeta []MyOtherType ` + "`" + `json:\"beta\"` + "`" + `\n\tDelta MyInteger ` + "`" + `json:\"delta,omitempty\"` + "`" + `\n\tEpsilon []custom.MyAlternateType ` + "`" + `json:\"epsilon\"` + "`" + `\n\tGamma fred.MyAlternateInteger ` + "`" + `json:\"gamma,omitempty\"` + "`" + `\n\tMeta MyType ` + "`" + `json:\"meta,omitempty\"` + "`" + `\n\n\tNullableBeta []*MyOtherType ` + "`" + `json:\"nullableBeta\"` + "`" + `\n\tNullableDelta *MyInteger ` + "`" + `json:\"nullableDelta,omitempty\"` + "`" + `\n\tNullableEpsilon []*custom.MyAlternateType ` + "`" + `json:\"nullableEpsilon\"` + "`" + `\n\tNullableGamma *fred.MyAlternateInteger ` + "`" + `json:\"nullableGamma,omitempty\"` + "`" + `\n\tNullableMeta MyType ` + "`" + `json:\"nullableMeta,omitempty\"` + "`" + `\n\n\tReqBeta []MyOtherType ` + "`" + `json:\"reqBeta\"` + "`" + `\n\tReqDelta *MyInteger ` + "`" + `json:\"reqDelta\"` + "`" + `\n\tReqEpsilon []custom.MyAlternateType ` + "`" + `json:\"reqEpsilon\"` + "`" + `\n\tReqGamma *fred.MyAlternateInteger ` + "`" + `json:\"reqGamma\"` + "`" + `\n\tReqMeta *MyType ` + "`" + `json:\"reqMeta\"` + "`" + `\n}\n",
  1018        "type": "object",
  1019        "required": [
  1020          "reqBeta",
  1021          "reqDelta",
  1022          "reqGamma",
  1023          "reqEpsilon",
  1024          "reqMeta"
  1025        ],
  1026        "properties": {
  1027          "beta": {
  1028            "description": "This property defines an array of external types (in the same package).\n\n[]MyOtherType\n\nThe maxItems validation is generated and the external validation is called for every item.\n",
  1029            "type": "array",
  1030            "maxItems": 15,
  1031            "items": {
  1032              "type": "object",
  1033              "x-go-type": {
  1034                "type": "MyOtherType"
  1035              }
  1036            }
  1037          },
  1038          "delta": {
  1039            "description": "A type is provided (integer), and the implementation is an external type in the same package.\n\nThe maximum validation remains documentary and is ignored by the generated code.\n",
  1040            "type": "integer",
  1041            "maximum": 15,
  1042            "x-go-type": {
  1043              "type": "MyInteger"
  1044            }
  1045          },
  1046          "epsilon": {
  1047            "type": "array",
  1048            "items": {
  1049              "type": "object",
  1050              "x-go-type": {
  1051                "import": {
  1052                  "alias": "custom",
  1053                  "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
  1054                },
  1055                "type": "MyAlternateType"
  1056              }
  1057            }
  1058          },
  1059          "gamma": {
  1060            "description": "Property defined as an external type from package \"fred\"\n",
  1061            "x-go-type": {
  1062              "import": {
  1063                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
  1064              },
  1065              "type": "MyAlternateInteger"
  1066            }
  1067          },
  1068          "meta": {
  1069            "$ref": "#/definitions/MyType"
  1070          },
  1071          "nullableBeta": {
  1072            "description": "This property defines an array of external types (in the same package).\n\n[]MyOtherType\n\nThe maxItems validation is generated and the external validation is called for every item.\n",
  1073            "type": "array",
  1074            "maxItems": 15,
  1075            "items": {
  1076              "type": "object",
  1077              "x-go-type": {
  1078                "hints": {
  1079                  "nullable": true
  1080                },
  1081                "type": "MyOtherType"
  1082              }
  1083            }
  1084          },
  1085          "nullableDelta": {
  1086            "description": "A type is provided (integer), and the implementation is an external type in the same package.\n\nThe maximum validation remains documentary and is ignored by the generated code.\n\nNullableDelta *MyInteger\n",
  1087            "type": "integer",
  1088            "maximum": 15,
  1089            "x-go-type": {
  1090              "type": "MyInteger"
  1091            },
  1092            "x-nullable": true
  1093          },
  1094          "nullableEpsilon": {
  1095            "description": "In this example, items are made nullable.\n\nNullableEpsilon []*custom.MyAlternateType ` + "`" + `json:\"nullableEpsilon\"` + "`" + `\n",
  1096            "type": "array",
  1097            "items": {
  1098              "type": "object",
  1099              "x-go-type": {
  1100                "import": {
  1101                  "alias": "custom",
  1102                  "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
  1103                },
  1104                "type": "MyAlternateType"
  1105              },
  1106              "x-nullable": true
  1107            }
  1108          },
  1109          "nullableGamma": {
  1110            "description": "Property defined as an external type from package \"fred\", with a nullable hint for the\nexternal type.\n\nNullableGamma *fred.MyAlternateInteger ` + "`" + `json:\"nullableGamma,omitempty\"` + "`" + `\n",
  1111            "x-go-type": {
  1112              "hints": {
  1113                "nullable": true
  1114              },
  1115              "import": {
  1116                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
  1117              },
  1118              "type": "MyAlternateInteger"
  1119            }
  1120          },
  1121          "nullableMeta": {
  1122            "x-nullable": true,
  1123            "$ref": "#/definitions/MyType"
  1124          },
  1125          "reqBeta": {
  1126            "type": "array",
  1127            "items": {
  1128              "type": "object",
  1129              "x-go-type": {
  1130                "type": "MyOtherType"
  1131              }
  1132            }
  1133          },
  1134          "reqDelta": {
  1135            "type": "integer",
  1136            "x-go-type": {
  1137              "type": "MyInteger"
  1138            }
  1139          },
  1140          "reqEpsilon": {
  1141            "type": "array",
  1142            "items": {
  1143              "type": "object",
  1144              "x-go-type": {
  1145                "import": {
  1146                  "alias": "custom",
  1147                  "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
  1148                },
  1149                "type": "MyAlternateType"
  1150              }
  1151            }
  1152          },
  1153          "reqGamma": {
  1154            "x-go-type": {
  1155              "import": {
  1156                "package": "github.com/go-swagger/go-swagger/examples/external-types/fred"
  1157              },
  1158              "type": "MyAlternateInteger"
  1159            }
  1160          },
  1161          "reqMeta": {
  1162            "$ref": "#/definitions/MyType"
  1163          }
  1164        }
  1165      }
  1166    }
  1167  }`))
  1168  }