Generating openAPI specification .yaml file with swagger gradle plugin results in a .yaml file with only one line: “openapi: 3.0.1”

  Kiến thức lập trình

What I want:

I want to generate the openapi.yaml file automatically using the swagger gradle plugin. My DTO classes have the @Schema annotation and my Resource files have the following annotations:

  @GET
  @Path("/id/{table-id}")
  @Operation

and so on. Here is a part of my Resource file:

  @GET
  @Path("/id/{table-id}")
  @Operation(
      summary = "Retrieves a table with the given id.",
      responses =
          @ApiResponse(
              responseCode = "200",
              description = "OK",
              content =
                  @Content(
                      mediaType = "application/json",
                      schema = @Schema(implementation = TableMetadataDTO.class))))
  public Response getTableMetadataByID(...) {...}

What I have:

I have the following code in my build.gradle file:

plugins {
    id 'java'
    id 'io.swagger.core.v3.swagger-gradle-plugin' version '2.2.22'
}

dependencies {
    implementation 'org.apache.commons:commons-lang3:3.12.0'
    implementation 'io.swagger.core.v3:swagger-jaxrs2-jakarta:2.2.9'
    implementation 'jakarta.ws.rs:jakarta.ws.rs-api:3.0.0'
    implementation 'jakarta.servlet:jakarta.servlet-api:5.0.0'
}

resolve {
    outputFileName = 'someOutputFile'
    outputFormat = 'YAML'
    classpath = sourceSets.main.output
    prettyPrint = 'TRUE'
    resourcePackages = ['hvs-app.src.main']
    outputDir = file('hvs-dto')
}

N.B. My project is written in java

What actually happens:

When I run the resolve task it generates the .yaml file but it contains only openapi: 3.0.1

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT