Matthias Andreas Benkard | 832a54e | 2019-01-29 09:27:38 +0100 | [diff] [blame^] | 1 | package swagger |
| 2 | |
| 3 | import ( |
| 4 | "net/http" |
| 5 | "reflect" |
| 6 | |
| 7 | "github.com/emicklei/go-restful" |
| 8 | ) |
| 9 | |
| 10 | // PostBuildDeclarationMapFunc can be used to modify the api declaration map. |
| 11 | type PostBuildDeclarationMapFunc func(apiDeclarationMap *ApiDeclarationList) |
| 12 | |
| 13 | // MapSchemaFormatFunc can be used to modify typeName at definition time. |
| 14 | type MapSchemaFormatFunc func(typeName string) string |
| 15 | |
| 16 | // MapModelTypeNameFunc can be used to return the desired typeName for a given |
| 17 | // type. It will return false if the default name should be used. |
| 18 | type MapModelTypeNameFunc func(t reflect.Type) (string, bool) |
| 19 | |
| 20 | type Config struct { |
| 21 | // url where the services are available, e.g. http://localhost:8080 |
| 22 | // if left empty then the basePath of Swagger is taken from the actual request |
| 23 | WebServicesUrl string |
| 24 | // path where the JSON api is avaiable , e.g. /apidocs |
| 25 | ApiPath string |
| 26 | // [optional] path where the swagger UI will be served, e.g. /swagger |
| 27 | SwaggerPath string |
| 28 | // [optional] location of folder containing Swagger HTML5 application index.html |
| 29 | SwaggerFilePath string |
| 30 | // api listing is constructed from this list of restful WebServices. |
| 31 | WebServices []*restful.WebService |
| 32 | // will serve all static content (scripts,pages,images) |
| 33 | StaticHandler http.Handler |
| 34 | // [optional] on default CORS (Cross-Origin-Resource-Sharing) is enabled. |
| 35 | DisableCORS bool |
| 36 | // Top-level API version. Is reflected in the resource listing. |
| 37 | ApiVersion string |
| 38 | // If set then call this handler after building the complete ApiDeclaration Map |
| 39 | PostBuildHandler PostBuildDeclarationMapFunc |
| 40 | // Swagger global info struct |
| 41 | Info Info |
| 42 | // [optional] If set, model builder should call this handler to get addition typename-to-swagger-format-field conversion. |
| 43 | SchemaFormatHandler MapSchemaFormatFunc |
| 44 | // [optional] If set, model builder should call this handler to retrieve the name for a given type. |
| 45 | ModelTypeNameHandler MapModelTypeNameFunc |
| 46 | } |