Swagger-ui: No operations defined in spec
See original GitHub issueHi,
I’ve been having issues setting up the swagger UI. I’ve getting ‘No operations defined in spec’ even though Swagger API at localhost:8080/v2/api-docs returns what looks like a valid output
My build.gradle contains this:
compile 'io.springfox:springfox-swagger2:2.8.0'
compile 'io.springfox:springfox-swagger-ui:2.8.0'
App is written in Kotlin, this is the main entry class
@SpringBootApplication
@EnableAutoConfiguration(exclude = [(JacksonAutoConfiguration::class)])
class Application
fun main(args: Array<String>) {
SpringApplicationBuilder()
.sources(Application::class.java)
.run(*args)
}
And Swagger config
@Configuration
@EnableSwagger2
class SwaggerConfig {
@Bean
fun api(): Docket {
return Docket(DocumentationType.SWAGGER_2)
.apiInfo(ApiInfoBuilder()
.title("Spring Boot project")
.description("Spring Boot bootstrap project")
.version("0.1")
.license("Unlicense")
.build())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
}
}
Any help would be appreciated as my Googlefoo has failed me here
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
No operations defined in spec! - I get this error even though ...
When I registered routes before swagger, it was showing 'no operations defined in specs':. fastify.register(require(".
Read more >No operations defined in spec! #248 - GitHub
using js-docs it renders no path doc at all. just a message: "No operations defined in spec!" pkgs: "swagger-jsdoc": "^6.0.0",
Read more >No operations defined in spec - IBM
If you see No operations defined in spec in the Swagger editor, the project is not yet ready for testing. Refresh the Swagger...
Read more >Solved: Error: "No operations defined in spec!" - using ES...
My implementation of Swagger is giving me "No operations defined in ... const swaggerUi = require('swagger-ui-express'); const bodyParser ...
Read more >Swagger UI
Swagger UI. Select a definition. Bursa Web Api V1. Bursa Web Api - (METRAMGMT-PRODUCTION) ... Bursa Web Api. No operations defined in spec!...
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 Free
Top 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
Just check if your basePackage is configured properly.
`@Bean public Docket greetingApi() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage(“application.controller”)) .build() .apiInfo(metaData());
Sigh… The problem was actually that I used GSON, which wrapped the entire JSON response from Swagger API into {value: “<actual Swagger content>”} object. The problem was hiding in plain sight, as is often in life…
Anyway, for anyone wondering how to fix this, add a new configuration bean like so
In hindsight, maybe Swagger should report a bit clearer message like “No data found” when nothing recognizable to it exists in the docs response, but that’s an issue for another repo