use of org.raml.v2.api.model.v10.methods.Method in project raml-for-jax-rs by mulesoft-labs.
the class V10Finder method typesInBodies.
private void typesInBodies(Resource resource, Method method, List<TypeDeclaration> body, GFinderListener listener) {
for (TypeDeclaration typeDeclaration : body) {
if (!isInline(typeDeclaration)) {
continue;
}
V10GType type = createInlineFromResourcesAndSuch(Names.ramlTypeName(resource, method, typeDeclaration), Names.javaTypeName(resource, method, typeDeclaration), typeDeclaration);
listener.newTypeDeclaration(type);
}
for (TypeDeclaration parameterTypeDeclaration : method.queryParameters()) {
if (!isInline(parameterTypeDeclaration)) {
continue;
}
V10GType type = createInlineFromResourcesAndSuch(Names.ramlTypeName(resource, method, parameterTypeDeclaration), Names.javaTypeName(resource, method, parameterTypeDeclaration), parameterTypeDeclaration);
listener.newTypeDeclaration(type);
}
for (TypeDeclaration headerType : method.headers()) {
if (!isInline(headerType)) {
continue;
}
V10GType type = createInlineFromResourcesAndSuch(Names.ramlTypeName(resource, method, headerType), Names.javaTypeName(resource, method, headerType), headerType);
listener.newTypeDeclaration(type);
}
for (Response response : method.responses()) {
for (TypeDeclaration typeDeclaration : response.body()) {
if (!isInline(typeDeclaration)) {
continue;
}
V10GType type = createInlineFromResourcesAndSuch(Names.ramlTypeName(resource, method, response, typeDeclaration), Names.javaTypeName(resource, method, response, typeDeclaration), typeDeclaration);
listener.newTypeDeclaration(type);
}
}
}
use of org.raml.v2.api.model.v10.methods.Method in project raml-for-jax-rs by mulesoft-labs.
the class V08Finder method typesInBodies.
private void typesInBodies(Resource resource, Method method, List<BodyLike> body, GFinderListener listener) {
for (BodyLike typeDeclaration : body) {
if (typeDeclaration.schema() == null) {
continue;
}
if (globalSchemas.containsKey(typeDeclaration.schema().value())) {
V08GType type = new V08GType(typeDeclaration.schema().value(), typeDeclaration);
registry.addType(type);
listener.newTypeDeclaration(type);
} else {
V08GType type = new V08GType(resource, method, typeDeclaration);
registry.addType(type);
listener.newTypeDeclaration(type);
}
}
for (Response response : method.responses()) {
for (BodyLike typeDeclaration : response.body()) {
if (typeDeclaration.schema() == null) {
continue;
}
if (globalSchemas.containsKey(typeDeclaration.schema().value())) {
V08GType type = new V08GType(typeDeclaration.schema().value(), typeDeclaration);
registry.addType(type);
listener.newTypeDeclaration(type);
} else {
V08GType type = new V08GType(resource, method, response, typeDeclaration);
registry.addType(type);
listener.newTypeDeclaration(type);
}
}
}
}
use of org.raml.v2.api.model.v10.methods.Method in project raml-for-jax-rs by mulesoft-labs.
the class CurrentBuild method fetchType.
public V10GType fetchType(Resource resource, Method method, Response response, TypeDeclaration typeDeclaration) {
if (typeDeclaration instanceof JSONTypeDeclaration) {
return (V10GType) ((JsonSchemaTypeGenerator) builtTypes.get(typeDeclaration.type())).getType();
}
if (typeDeclaration instanceof XMLTypeDeclaration) {
return (V10GType) ((XmlSchemaTypeGenerator) builtTypes.get(typeDeclaration.type())).getType();
}
RamlToPojo ramlToPojo = fetchRamlToPojoBuilder();
if (ramlToPojo.isInline(typeDeclaration)) {
TypeName typeName = fetchRamlToPojoBuilder().fetchType(Names.javaTypeName(resource, method, response, typeDeclaration), typeDeclaration);
V10RamlToPojoGType type = new V10RamlToPojoGType(Names.javaTypeName(resource, method, response, typeDeclaration), typeDeclaration);
type.setJavaType(typeName);
return type;
} else {
TypeName typeName = fetchRamlToPojoBuilder().fetchType(typeDeclaration.type(), typeDeclaration);
V10RamlToPojoGType type = new V10RamlToPojoGType(typeDeclaration.type(), typeDeclaration);
type.setJavaType(typeName);
return type;
}
}
use of org.raml.v2.api.model.v10.methods.Method in project raml-for-jax-rs by mulesoft-labs.
the class V10Finder method resourceTypes.
private void resourceTypes(List<Resource> resources, GFinderListener listener) {
for (Resource resource : resources) {
resourceTypes(resource.resources(), listener);
for (TypeDeclaration parameterTypeDeclaration : resource.uriParameters()) {
if (!isInline(parameterTypeDeclaration)) {
continue;
}
V10GType type = createInlineFromResourcesAndSuch(Names.ramlTypeName(resource, parameterTypeDeclaration), Names.javaTypeName(resource, parameterTypeDeclaration), parameterTypeDeclaration);
listener.newTypeDeclaration(type);
}
for (Method method : resource.methods()) {
typesInBodies(resource, method, method.body(), listener);
}
}
}
use of org.raml.v2.api.model.v10.methods.Method in project raml-for-jax-rs by mulesoft-labs.
the class CurrentBuild method fetchType.
public V10GType fetchType(Resource implementation, Method method, TypeDeclaration typeDeclaration) {
if (typeDeclaration instanceof JSONTypeDeclaration) {
return (V10GType) ((JsonSchemaTypeGenerator) builtTypes.get(typeDeclaration.type())).getType();
}
if (typeDeclaration instanceof XMLTypeDeclaration) {
return (V10GType) ((XmlSchemaTypeGenerator) builtTypes.get(typeDeclaration.type())).getType();
}
RamlToPojo ramlToPojo = fetchRamlToPojoBuilder();
if (ramlToPojo.isInline(typeDeclaration)) {
TypeName typeName = ramlToPojo.fetchType(Names.javaTypeName(implementation, method, typeDeclaration), typeDeclaration);
V10RamlToPojoGType type = new V10RamlToPojoGType(Names.javaTypeName(implementation, method, typeDeclaration), typeDeclaration);
type.setJavaType(typeName);
return type;
} else {
TypeName typeName = ramlToPojo.fetchType(typeDeclaration.type(), typeDeclaration);
V10RamlToPojoGType type = new V10RamlToPojoGType(typeDeclaration.type(), typeDeclaration);
type.setJavaType(typeName);
return type;
}
}
Aggregations