Skip to content

No operations defined in spec! #862

@mikt

Description

@mikt

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions