How can we generate the OpenAPI Yaml file (Swagger file) from Spring boot API without running the application?

How can we generate the OpenAPI Yaml file (Swagger file) from Spring boot API without running the application?
For example,
INPUT: Springboot API:
@RequestMapping(method = RequestMethod.GET, value = “getlength”)
public @ResponseBody int getLength(@RequestParam string s)
{

}
OUTPUT: Swagger specification
getLength:
get:
operationId: “getLength”
parameters:

  • name: “s”
    in: “query”
    type: “string”
    responses:
    201:
    description: “Successful response 201”
    schema:
    type: “integer”