Releases: manusant/spark-swagger
Releases · manusant/spark-swagger
v2.0.8
v2.0.7
2.0.6
2.0.5
2.0.4
2.0.3
2.0.2
Changeset
- Add Spark-Swagger Options configuration object as a builder.
Service spark = Service.ignite()
.ipAddress("localhost")
.port(8081);
Options.builder()
.confPath(SparkSwagger.CONF_FILE_NAME)
.version("1.0.0")
.enableCors(true)
.enableStaticMapping(true)
.build();
SparkSwagger.of(spark, options)
.endpoints(() -> Arrays.asList(new HammerEndpoint(), new ShieldEndpoint()))
.generateDoc();
- Adapt Route interface to have Route and TypedRoute components
.get(path()
.withDescription("Gets the available shields")
.withResponseAsCollection(Shield.class), new Route() {
@Override
public Object onRequest(Request request, Response response) {
Shield shield = Shield.builder()
.id("sh_123456")
.name("Thor Main Shield")
.owner("Manuel Santos")
.defense(10)
.build();
return ok(response, Arrays.asList(shield));
}
})
or
.post(path("/:id")
.withDescription("Get Shield by ID")
.withRequestType(BackupRequest.class)
.withResponseType(Shield.class), new TypedRoute<BackupRequest>() {
@Override
public Object onRequest(BackupRequest body, Request request, Response response) {
return badRequest(response, "Invalid shield ID");
}
})
- Fix issue with path definitions and conflict between swagger spec and actual route path
- Include @content annotation as a way to specify content type, marshaling and unmarshaling
.post(path("/backup")
.withDescription("Trigger Network Backup")
.withRequestType(BackupRequest.class)
.withGenericResponse(),
new TypedRoute<BackupRequest>() {
@Content(ContentType.APPLICATION_JSON)
public Object onRequest(BackupRequest body, Request request, Response response) {
return badRequest(response, "Backup Name required in order to backup Network Data");
}
})
- Fix swagger specification for responseAsCollection
- Add option for responseAsMap
.get(path("/options")
.withDescription("Gets all shield options")
.withResponseAsMap(Shield.class), new Route() {
@Override
public Object onRequest(Request request, Response response) {
Map<String, Shield> shields = new HashMap<>();
Shield thor = Shield.builder()
.id("sh_123456")
.name("Thor Shield")
.owner("Manuel Santos")
.defense(50)
.build();
shields.put("thor",thor);
Shield loki = Shield.builder()
.id("sh_255678")
.name("Loki Shield")
.owner("Manuel Santos")
.defense(20)
.build();
shields.put("loki",loki);
return ok(response, shields);
}
})
- Fix issue supplying version config
- Include static mapping enable config
- Add option to load UI resources from project resources besides from artifact jar, locally (for testing purpose)