mulesoft-labs / raml-for-jax-rs

This project is all about two way transformation of JAX-RS-annotated Java code to RAML API description and back.
Other
295 stars 181 forks source link

No schema generated #8

Closed prm2612 closed 10 years ago

prm2612 commented 10 years ago

I am using the anypoint studio plugin (version 1.0.0.201407032152). When I right click and select "Generate RAML from classes", it generates RAML file which is referring to JSON file under examples directory. But there is no JSON file generated for my domain object there. I am using JAXB annotations in my domain class.

Following are the 2 classes based on which I am trying to generate RAML:

Domain class:

import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name = "person") @XmlType(propOrder = {"id", "name"}) public class Person {

private int id;

private String name;

@XmlElement(name = "id")
public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}

@XmlElement(name = "person_name")
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}   

}

Resource interface:

import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType;

@Path("/persons") public interface PersonResource { @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("{personId}") public Person getPerson(@PathParam("personId") int personId);

}

RAML:

%RAML 0.8

title: jaxrs2raml test version: v1 baseUri: "http://localhost:9999" protocols: [ HTTP ] /persons: /{personId}: uriParameters: personId: type: integer required: true get: responses: 200: body: application/xml: schema: person example: !include examples/person.xml application/json: schema: person-jsonschema example: !include examples/person.json

If I select "Generate schemas and examples in a single RAML file", following stacktrace appears:

java.lang.RuntimeException: resource not found: examples/person.xml at org.raml.parser.visitor.PreservingTemplatesBuilder.onCustomTagError(PreservingTemplatesBuilder.java:33) at org.raml.parser.tagresolver.IncludeResolver.resolve(IncludeResolver.java:69) at org.raml.parser.visitor.NodeVisitor.resolveTag(NodeVisitor.java:141) at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:121) at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:69) at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:223) at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:159) at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:129) at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:69) at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:223) at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:159) at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:129) at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:69) at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:223) at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:159) at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:129) at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:69) at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:223) at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:159)

petrochenko-pavel-a commented 10 years ago

Looking

petrochenko-pavel-a commented 10 years ago

This issue should not appear with the newest version of plugin