Spring initiative investigation
Goal:
The main goal of the spike was investigation if the proposed plugin meets project initial requirements.
Initial requirements:
for endpoints it has to generate interfaces or classes that could be extended to implement the necessary logic [MUST];
support !include directive in RAML files like below :
types: note: !include note.json noteCollection: !include noteCollection.json errors: !include raml-util/schemas/errors.schemasupport definition of a single element in collection as $ref
Investigation results:
Initial requirement:
for endpoints it has to generate interfaces or classes that could be extended to implement the necessary logic [MUST];
Result:
Pros: ability to create Controllers and Models from the raml file
The plugin provides several rules an ability to generate interfaces. To achiev this you have to specify the rule name in pom.xml file
<configuration>
<rule>com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4ControllerInterfaceRule</rule>
</configuration>
Here is the raml file which were used to test:
this are the Controllers generated by plugin:
and Models
Summary
Pros: ability to create Controllers and Models from the raml file
Cons: properties do not have Jackson annotations like
@JsonProperty("customerId")
@JsonPropertyDescription("Customer ID using the KB")
@NotNull
private String customerId;Rules description can be found here https://github.com/phoenixnap/springmvc-raml-plugin#rule
Sample module can be found here. The pom file which uses this rule can be found here