avaje/avaje-http

Make OpenAPI javadocs inheritable

SentryMan opened this issue · 1 comments

So was talking to this guy who wants

@Path("javalin")
@OpenAPIDefinition(
    info =
        @Info(
            title = "Example service",
            description = "Example Javalin controllers with Java and Maven"))
public interface ControllerClass {
  
  /**
   * Standard Get
   *
   * @return a health check
   */
  @Get("/health")
  @Produces(MediaType.TEXT_PLAIN)
  @OpenAPIResponse(responseCode = "400", type = ErrorResponse.class)
  String health();

@Controller
public class ControllerClassImpl implements ControllerClass {

  @Override
  public String health() {

    return "healthlmao";
  }
}

This currently generates.

{
	"openapi" : "3.0.1",
	"info" : {
		"title" : "Example service",
		"description" : "Example Javalin controllers with Java and Maven",
		"version" : ""
	},
	"paths" : {
		"/javalin/health" : {
			"get" : {
				"tags" : [
					
				],
				"summary" : "",
				"description" : "",
				"responses" : {
					"200" : {
						"description" : "",
						"content" : {
							"text/plain" : {
								"schema" : {
									"type" : "string"
								}
							}
						}
					}
				}
			}
		}
	},
	"components" : {
		"schemas" : {
			
		}
	}
}

What I'd expect to happen

You'd expect that the openAPI would work off the interface

{
	"openapi" : "3.0.1",
	"info" : {
		"title" : "Example service",
		"description" : "Example Javalin controllers with Java and Maven",
		"version" : ""
	},
	"paths" : {
		"/javalin/health" : {
			"get" : {
				"tags" : [
					
				],
				"summary" : "Standard Get",
				"description" : "",
				"responses" : {
					"400" : {
						"description" : "",
						"content" : {
							"text/plain" : {
								"schema" : {
									"$ref" : "#/components/schemas/ErrorResponse"
								}
							}
						}
					},
					"200" : {
						"description" : "a health check",
						"content" : {
							"text/plain" : {
								"schema" : {
									"type" : "string"
								}
							}
						}
					}
				}
			}
		}
	},
	"components" : {
		"schemas" : {
			"ErrorResponse" : {
				"type" : "object",
				"properties" : {
					"id" : {
						"type" : "string"
					},
					"text" : {
						"type" : "string"
					}
				}
			}
		}
	}
}

Looks done - well done !!