Open ljheric opened 5 years ago
I'm at work right now.
This is generated by jsonschematoobject. Have you activated the options on this?
I have no idea about it, could you give some instruction how to activate this option? Thank you !
A quick examples on how to configure the jsonMapper is here:
The options are defined here (specifically the definition on jsr 303 annotations): https://github.com/mulesoft-labs/raml-for-jax-rs/blob/0344116cbb3f8259425a6b9e4575cee62276abed/raml-to-jaxrs/jaxrs-code-generator/src/main/java/org/raml/jaxrs/generator/RamlToJaxRSGenerationConfig.java#L48
Here is my maven plugin configuration:
<plugin>
<groupId>org.raml.plugins</groupId>
<artifactId>raml-jaxrs-maven-plugin</artifactId>
<version>1.3.4</version>
<configuration>
<!-- Use sourcePaths if you want to provide a single RAML file or a
list of RAML files -->
<sourceDirectory>api/internal</sourceDirectory>
<!-- Optionally configure outputDirectory if you don't like the default
value: ${project.build.directory}/generated-sources/raml-JAX-RS -->
<basePackageName>com.sap.mcp.collaboration.gen</basePackageName>
<jaxrsVersion>2.0</jaxrsVersion>
<useJsr303Annotations>true</useJsr303Annotations>
<jsonMapper>jackson2</jsonMapper>
<jsonMapperConfiguration>
<includeHashcodeAndEquals>true</includeHashcodeAndEquals>
</jsonMapperConfiguration>
<removeOldOutput>true</removeOldOutput>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
Is that right? I have tried many times, the @valid annotation can't be generated, following is the generated code
@POST @Consumes("application/json") @Produces({ "application/json" }) CollaborationRoomsResource.PostCollaborationRoomsResponse postCollaborationRooms(CollaborationRoomCreateRequest entity) throws Exception ;
What I expected is to add @valid annotation for the parameter "CollaborationRoomCreateRequest entity", how to do that? Thank you!
I am using raml-jaxrs-maven-plugin with verion 1.3.4 to generate resource code, but the @valid annotation can't be generated. Following is the code
raml file
/collaborationRooms: post: body: schema: CollaborationRoomCreateRequest responses: 201:
type
{ "$schema": "http://json-schema.org/draft-4/schema", "type": "object", "description": "Collaboration room", "javaType" : "com.mcp.api.model.CollaborationRoomCreateRequest", "properties": { "name": { "description":"The name of a collaboration room", "required": true, "type": "string" } }