RAML to Java POJO


#1

I am working on data integration between 2 organisations . Other company is sending data as JSON now I want to validate the JSON data and transfer to DTO’s . I have a Sample.raml file provided by vender . now I want to generate a DTO’s using RAML file in my application to hold the JSON data which is going to send by vender . can you please let me know is it possible to create a POJO’s or DTOS from RAML . if YES can you give any suggest me . appreciate your help in advance.

Thanks
Raja.


#2

Have you tried scraml? It’s a client generator, but you also get the DTO’s. Inheritance and multiple inheritance is supported, union types not yet.


#3

i) You can perform JSON payload validation using the JSON schemas and give a reference inside the RAML file as described below:
/test:
post
body:
application/json:
example: !include examples/sample-request-input.json
schema: !include schemas/sample-request-input.json

ii) Also, create examples and schemas along with api.raml in order to generate the POJOs based on JSON Schemas using RAML-to-JAX-RS.


iii) Mule flows can easily transform JSON-to-Object (POJOs) & vice-versa easily using the transformers in order to handle input/output in required data format.


#4

@Peter_Rigole scraml looks like not free to use . definitely will try this as no other free options available


#5

Hi @Niraj Thnaks a lot for your replay. I forgot to mention my webapplication is receiving data(JSON) from mule. but I couldn’t find the JsonSchema in the sample.raml file they provided.

I agree with you if they provide the Jsonschema alone with sample.raml it is easy for me to validate the JSON data against JSONSchema and also converting JSONSchema to POJO’s.

how complex is it to create a jsonschema for mule and provided me as part of sample.raml , looks like it is mandatory.

Thnaks
Raja.


#6

@Peter_Rigole scraml looks like not free to use . definitely will try this as no other free options available , Thanks a lot Peter


#7

We’re going to relax the license for non-commercial use, so that you can generate code with the license that you choose. That way the generated code won’t be AGPL any longer, but whatever you want.