question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No operations defined in spec!

See original GitHub issue

Hi, So I attempted to follow the getting started guide, and get inspiration from the sample projects, however for some reason my endpoint or models are not visible on the swagger UI, instead I’m faced with “No operations defined in spec!”

I would appreciate any tips to what I’ve might have missed 😃

My controller/interface:

@Tag(name = "Test", description = "Just a test endpoint")
@RequestMapping(value = DEFAULT_PATH, produces = APPLICATION_JSON_VALUE)
@RestController
public interface TestEndpoint {
    String DEFAULT_PATH = "/test";

    String ID = "/{test-id}";

    @Operation(
            description = "Get test by test-id",
            summary = "Get test summary"
    )
    @ResponseStatus(code = HttpStatus.OK)
    @ApiResponses({
            @ApiResponse(
                    responseCode = HttpURLConnection.HTTP_OK + "",
                    description = "The request succeeded.",
                    content = @Content(schema = @Schema(implementation = TestModel.class))
            )
    })
    @GetMapping(value = ID)
    TestModel getAgreement(@Parameter(description = "Id of the test", required = true) @PathVariable("test-id") Long testId);
}

Application properties:

server.port=8090
application-description=@project.description@
application-version=@project.version@
springdoc.packages-to-scan=*
springdoc.paths-to-match=/*

My application runner

@SpringBootApplication
public class AuthApplication {

    @Bean
    public OpenAPI springShopOpenAPI(@Value("${application-version}") String appVersion) {
        return new OpenAPI()
                .info(new Info().title("HoN Core Auth API")
                        .description("Authentication & authorization API")
                        .version(appVersion)
                        .license(new License().name("(C) HoN")));
    }

//    @Bean
//    public GroupedOpenApi publicApi() {
//        String[] paths = {TestEndpoint.DEFAULT_PATH.concat("/**")};
//        return GroupedOpenApi.builder()
//                .group("public")
//                .pathsToMatch(paths)
//                .build();
//    }

    public static void main(String[] args) {
        SpringApplication.run(AuthApplication.class, args);
    }

}

My model:

@Schema(description = "This model represents a test result")
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@Builder
@Data
public class TestModel {
    @Schema(description = "Test description", example = "First test case")
    String description;

    @Schema(description = "Test id", example = "1", required = true)
    @NotNull
    Long id;

    @Schema(description = "Was the test a success", example = "true", required = true)
    @NotNull
    Boolean isSuccess;
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
bnasslahsencommented, Apr 7, 2022

@jerryleooo,

Your config is wrong. You are inverting the group and the package.

This is the correct configuration.

  @Bean
  public GroupedOpenApi api()
  {
      return GroupedOpenApi.builder()
              .group("OpenApiController")
              .packagesToScan("com.example")
              .build();
  }
1reaction
bnasslahsencommented, Sep 12, 2020

@mikt,

This can be contract, but an interface is not going to generate a spring controller. If the controller does not effectively exist, springdoc-openapi will not detect it.

You need to add the implementation class even it’s not yet complete… You can have a look at the project tests for samples.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No operations defined in spec! - I get this error even though ...
I am trying to setup swagger on top of my node application using the swagger npm package. I have my end points and...
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 >
No operations defined in spec! #66 - swaggo/echo-swagger
I follow the echo-wagger README tutorial and get the error bellow And I google so many times and have no answer. so any...
Read more >
Solved: Error: "No operations defined in spec!" - using ES...
My problem is that I've started a React Native project that needs to consume my own API, but we're using ES6 javascripts with...
Read more >
Paths and Operations - Swagger
Swagger defines a unique operation as a combination of a path and an HTTP method. This means that two GET or two POST...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found