Lots of miscellaneous definitions are being created in swagger, how can I limit these to a package?
See original GitHub issue- Version: 2.9.0
I’m currently running into an odd issue where I am getting a lot of miscellaneous models being added to my definitions. Is there a way to control which packages Springfox looks at for definition creation?
Here is my current configuration, which lives in a @Component
that has @EnableSwagger2
:
@Bean
Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.my.package.controller"))
.build()
.pathMapping('/')
}
and here is a small subset of the definitions being generated:
"ASTNode": {
"type": "object",
"properties": {
"columnNumber": {
"type": "integer",
"format": "int32"
},
"lastColumnNumber": {
"type": "integer",
"format": "int32"
},
"lastLineNumber": {
"type": "integer",
"format": "int32"
},
"lineNumber": {
"type": "integer",
"format": "int32"
},
"nodeMetaData": {
"type": "object"
},
"sourcePosition": {
"$ref": "#/definitions/ASTNode"
},
"text": {
"type": "string"
}
},
"title": "ASTNode"
},
"AnnotatedType": {
"type": "object",
"properties": {
"annotations": {
"type": "array",
"items": {
"$ref": "#/definitions/Annotation"
}
},
"declaredAnnotations": {
"type": "array",
"items": {
"$ref": "#/definitions/Annotation"
}
},
"type": {
"$ref": "#/definitions/Type"
}
},
"title": "AnnotatedType"
},
"Annotation": {
"type": "object",
"title": "Annotation"
},
```
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
OpenAPI Specification - Version 2.0 - Swagger
Version 2.0 specification defines a set of files required to describe an API. These files can then be used by the Swagger-UI project...
Read more >Inheritance and Polymorphism - Swagger
OAS 3 This guide is for OpenAPI 3.0. Inheritance and Polymorphism. Model Composition. In your API, you may have model schemas that share...
Read more >Configuration - Swagger Documentation
Configuration. How to configure. Swagger UI accepts configuration parameters in four locations. From lowest to highest precedence: The swagger-config.yaml ...
Read more >Describing Responses - Swagger
OAS 2 This page applies to OpenAPI Specification ver. ... A response is defined by its HTTP status code and the data returned...
Read more >Open API | Documentation - ServiceStack Docs
Open API is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ahatzz11 thats awesome! glad you figured it out. Yes the meta class does cause additional models to be generated. However I did not realize how many. It would certainly be nice to add it, but thats not really part of this library. At the core, springfox doesnt/should not care about what the target language/framework is.
I just deleted all of my models except for one to test this out. This leftover model has a single
String
in it. When I generate my swagger through Springfox it is still pulling in all of these additional models. Here is the modelTestRequest.groovy
:I tried to convert this model to a java class -
TestRequest.java
, and all of the extra models in the swagger spec disappeared. It seems there’s an issue with between groovy and springfox.Some additional details:
I continued to play and I think I found a solution. I was looking at #752 and decided to try ignoring the groovy
MetaClass
in my docket creation.This ends up removing all of the extra classes that were created in the definitions.
Is this intended behavior? It would be cool if springfox was able to automatically filter out all the groovy classes that are found. This creates a lot of noise in swagger specs.