@Deprecated public class Raml extends Object
RESTful API Modeling Language (RAML) makes it easy to manage the whole API lifecycle from design to sharing. It's concise - you only write what you need to define - and reusable. It is machine readable API design that is actually human friendly. More at http://raml.org
NOTE: This modules depends on RouteSpec
, please read the
RouteSpec
to learn how to use this tool.
{ // define your API... via script or MVC: / * * * Everything about your pets */ use("/api/pets") / * * * Get a pet by ID. * @param id Pet ID */ .get("/:id", req -> { int id = req.param("id").intValue(); DB db = req.require(DB.class); Pet pet = db.find(Pet.class, id); return pet; }) ...; new Raml().install(this); }
You also need the jooby:spec
maven plugin:
<plugin> <groupId>org.jooby</groupId> <artifactId>jooby-maven-plugin</artifactId> <executions> <execution> <goals> <goal>spec</goal> </goals> </execution> </executions> </plugin>
The plugin compiles the API and produces a .spec
file for prod environments.
The RAML api-console will be available at /raml
and the .raml
will be
at: /raml/api.raml
There are a few options available, let's see what they are:
The path
option controls where to mount the RAML routes:
{ ... new Raml("docs").install(this); }
Produces: /docs
for api-console and /docs/api.raml
. Default path is:
/raml
.
The filter
option controls what is exported to RAML:
{ ... new Raml() .filter(route -> { return route.pattern().startsWith("/api"); }) .install(this); }
Default filter keeps /api/*
routes.
This option turn off the api-console:
{ ... new Raml() .noConsole() .install(this); }
Set the ui-theme for api-console. Available options are light
and dark
.
Default is: light
.
{ ... new Raml() .theme("dark") .install(this); }
Shows/hide the client generator button from api-console.
Expand/collapse the try it panel from api-console.
Constructor and Description |
---|
Raml()
Deprecated.
Creates a new
Raml under the /raml path. |
Raml(String path)
Deprecated.
Creates a new
Raml . |
Modifier and Type | Method and Description |
---|---|
Raml |
clientGenerator(boolean enabled)
Deprecated.
Shows/hide client generator button for api-console.
|
Raml |
filter(Predicate<RouteSpec> filter)
Deprecated.
Apply a route filter.
|
void |
install(org.jooby.Jooby app)
Deprecated.
Install
Raml in the given app. |
Raml |
noConsole()
Deprecated.
Turn off api-console.
|
Raml |
theme(String theme)
Deprecated.
Set a ui-theme for api-console.
|
Raml |
tryIt(boolean enabled)
Deprecated.
Expand/collapse the try-it panel for api-console.
|
public Raml()
Raml
under the /raml
path.public Raml filter(Predicate<RouteSpec> filter)
/api
will be exported.filter
- A route filter.public Raml theme(String theme)
theme
- Dark or light. Default is light.public Raml clientGenerator(boolean enabled)
enabled
- True shows the button.public Raml tryIt(boolean enabled)
enabled
- True expands the panel.public Raml noConsole()
public void install(org.jooby.Jooby app)
Raml
in the given app.app
- An application.Copyright © 2018. All rights reserved.