Skip to content

ICIJ/fluent-swagger-apigen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fluent-swagger-apigen

Java CI

This repository provides a utility jar to scan your fluent-http resources and create an openAPI specification file.

It is a work in progress.

How to use it?

Good old way

You need to build or download the fluent-swagger-apigen jar. Then you have to call the Main class that will scan classpath resources with the @Prefix annotation.

It will create an openapi.yml file with the specifications.

Example:

java -cp path/to/fluent-swagger-apigen-0.1-jar-with-dependencies.jar:path/to/your/fluent/http/jar org.icij.swagger.Main your.resources.package.name

With jbang

First install jbang

Then use it:

jbang run --cp path/to/your/fluent/webapp.jar fluentopenapi.java

Or with github:

jbang run --cp path/to/your/fluent/webapp.jar  https://github.com/ICIJ/fluent-swagger-apigen/blob/main/src/main/java/fluentopenapi.java

How to document resources

You will find a small example of a fluent petstore in the tests.

It is based on the swagger annotations v3.

Example:

@Operation(description = "Deletes a pet")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "returns true if deleted", useReturnTypeSchema = true),
                        @ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
                        @ApiResponse(responseCode = "404", description = "Pet not found")})
@Delete("/:petId")
public boolean deletePet(@Parameter(description = "Pet id to delete", in = ParameterIn.PATH, required = true) Long petId) {
    return petData.deletePet(petId);
}