-
Notifications
You must be signed in to change notification settings - Fork 4
Properties
The following properties are used by the different jsonhome modules.
In Spring applications, the properties can be configured in a .properties
file and injected into the different Spring beans using a PropertyPlaceHolderConfigurer
:
<context:property-placeholder
location="/WEB-INF/properties/shop.properties"
ignore-resource-not-found="false"/>
The values of the properties can also be set or overridden using system-environment variables using Java VM options:
-Djsonhome.relationTypeBaseUri=http://specs.otto.de:8082
-Djsonhome.applicationBaseUri=http://example.org:8081/shop
If you are using the jsonhome-jersey module, the properties must be set in a properties file de/otto/jsonhome/jsonhome.properties
.
This property is used by the generators (Spring, Jersey) to create absolute href
and href-template
attributes in json-home documents pointing to REST resources.
Example:
jsonhome.applicationBaseUri = http://example.org/shop
If, for example, a controller has a resource mapping like @RequestMapping("/storefront")
, the application's base URI is used as a prefix. In the above example, the resulting href
in the json-home document will be http://example.org/shop/storefront
.
The relationTypeBaseUri is used similar to the applicationBaseUri. It is used as a prefix to build absolute URIs for a link-relation type.
Example:
jsonhome.relationTypeBaseUri = http://specs.example.org/shop
will create link-relation types for a resource with @Rel("/rel/product")
like this:
{ "resources" : {
"http://specs.example.org/shop/rel/product": {
"href-template": "http://example.org/shop/products/{productId}",
It is recommendable, to configure this property in a way, that the resulting URIs are resolvable, pointing a developer to a documentation about the link-relation type. Because it is definitely NOT recommendable, to use URIs that are different on multiple machines (the worst would be something like http://localhost:8080), you may want to consider using a jsonhome-registry server.
[TODO: link to documentation about the registry server]
This base URI is used to build the href-vars of templated links.
By default, the URIs will be generated as a fragment of the corresponding link-relation type. A productId
parameter, for example, will be created like this:
{ "resources" : {
"http://example.org/rel/product": {
"href-template": "http://example.org/shop/products/{productId}",
"href-vars": {
"productId": "http://example.org/rel/product#productId"
}
Example:
jsonhome.varTypeBaseUri=
If you prefer a different base URI to create the href-vars
, you must set the property with a different value:
jsonhome.varTypeBaseUri=http://example.org/param
This way, you will get a result like this:
"http://example.org/rel/product": {
"href-template": "http://example.org/shop/products/{productId}",
"href-vars": {
"productId": "http://example.org/param/productId"
}
The @Docs
annotation can be used to include documentation from a Markdown document into the HTML documentation of a HTTP API. See Using the @Doc annotation for details.
The Markdown documents must be located in the classpath of the application. The properties jsonhome.docRootDir
will be used to find the root folder of these documents:
jsonhome.docRootDir=/docs/*
If you are not using Markdown, you may leave this property empty.
This property is only used by the jsonhome-registry
to select the name of the registry that is used if no registry is specified.
[TODO: add documentation page about jsonhome-registry]
Example:
jsonhome.defaultRegistry = default