@Override public String defaultValue() { return input.defaultValue(); }
public void setupTypeHierarchy(TypeDeclaration typeDeclaration) { List<TypeDeclaration> parents = typeDeclaration.parentTypes(); for (TypeDeclaration parent : parents) { setupTypeHierarchy(parent); childTypes.put(parent.name(), typeDeclaration.name()); } }
@Nullable @Override public String apply(@Nullable TypeDeclaration input) { return "\"" + input.name() + "\""; } });
debug("Param name " + x.name()); debug("Param Data type " + x.type()); debug("Param Is Required " + x.required()); }); debug("Header name " + res.name()); if (res.example() != null) { debug("Header value " + res.example().value()); if (b.displayName() != null) debug("Content Type " + b.displayName().value()); if (b.example() != null) { debug("Body " + b.example().value()); String contentType = (b.displayName() != null) ? b.displayName().value() : null; debug("Content Type " + contentType); String responseBody = (b.example() != null) ? b.example().value() : null; debug("Body " + responseBody); final String headerName = res.name(); debug("Header name " + headerName); final String headerValue = (res.example() != null) ? res.example().value() : null; debug("Header value " + headerValue);
@Override public RamlInterpretationResult interpret(RamlRoot document, TypeDeclaration type, JCodeModel builderModel, boolean property) { RamlInterpretationResult result = new RamlInterpretationResult(type.required()); typeCheck(type); return interpret(document, type.parentTypes().get(0), builderModel, property); typeName = types.get(name).getType().type(); MimeType.valueOf(name); name = typeName; typeName = types.get(name).getType().type(); if (!StringUtils.isEmpty(objectType.discriminator())) { for (RamlDataType ramlDataType : document.getTypes().values()) { if (name.equals(ramlDataType.getType().type())) { childTypes.add(ramlDataType); if (!RamlTypeHelper.isBaseObject(tempParent.name())) { parent = types.get(tempParent.name()).getType(); if (parent != null && !(parent.name().equalsIgnoreCase(name))) { // add if (Config.getOverrideNamingLogicWith() == OverrideNamingLogicWith.DISPLAY_NAME && objectProperty.displayName() != null) { fieldName = NamingHelper.getParameterName(objectProperty.displayName().value()); } else if (Config.getOverrideNamingLogicWith() == OverrideNamingLogicWith.ANNOTATION) { for (AnnotationRef annotation : objectProperty.annotations()) { if ("(javaName)".equals(annotation.name())) { fieldName = String.valueOf(annotation.structuredValue().value());
@Override public String getRawType() { return this.formParameter.type(); } }
@Override public MethodSpec.Builder setterBuilt(ObjectPluginContext objectPluginContext, TypeDeclaration declaration, MethodSpec.Builder methodSpec, EventType eventType) { AnnotationSpec.Builder annotation = AnnotationSpec.builder(JsonProperty.class) .addMember("value", "$S", declaration.name()); if (declaration.defaultValue() != null) { annotation.addMember("defaultValue", "$S", declaration.defaultValue()); } return methodSpec.addAnnotation(annotation.build()); } }
if (extending instanceof StringTypeDeclaration && extending.type() != null && extending.type().equals("string") && ((StringTypeDeclaration) extending).enumValues().size() > 0 && extended.length == 1 && extended[0] instanceof StringTypeDeclaration) { if (extending.parentTypes().size() > 1) { if (extending.type() != null && extending.type().equals("object")) {
TypeDeclaration typeDeclaration = response.body().get(0); if(typeDeclaration.example() != null){ String body = typeDeclaration.example().value(); restMockResponse.setBody(body); for(TypeDeclaration parameter : response.headers()){ HttpHeader httpHeader = new HttpHeader(); httpHeader.setName(parameter.name()); httpHeader.setValue(parameter.defaultValue()); restMockResponse.getHttpHeaders().add(httpHeader);
if (StringUtils.hasText(typeDeclaration.defaultValue())) { if (resolvedType.name().equals(Integer.class.getSimpleName())) { jExpression = JExpr.lit(Integer.valueOf(typeDeclaration.defaultValue())); } else if (resolvedType.name().equals(Boolean.class.getSimpleName())) { jExpression = JExpr.lit(Boolean.valueOf(typeDeclaration.defaultValue())); } else if (resolvedType.name().equals(Double.class.getSimpleName())) { jExpression = JExpr.lit(Double.valueOf(typeDeclaration.defaultValue())); } else if (resolvedType.name().equals(Float.class.getSimpleName())) { jExpression = JExpr.lit(Float.valueOf(typeDeclaration.defaultValue())); } else if (resolvedType.name().equals(Long.class.getSimpleName())) { jExpression = JExpr.lit(Long.valueOf(typeDeclaration.defaultValue())); } else if (resolvedType.name().equals(BigDecimal.class.getSimpleName())) { jExpression = JExpr.direct("new BigDecimal(\"" + typeDeclaration.defaultValue() + "\")"); } else if (resolvedType.name().equals(String.class.getSimpleName())) { jExpression = JExpr.lit(typeDeclaration.defaultValue()); } else if (type.contains(".") && resolvedType instanceof JDefinedClass && ((JDefinedClass) resolvedType).getClassType().equals(ClassType.ENUM)) { jExpression = JExpr.direct(resolvedType.name() + "." + NamingHelper.cleanNameForJavaEnum(typeDeclaration.defaultValue())); if (!Objects.equals(typeDeclaration.name(), toJavaName(name))) { field.annotate(JsonProperty.class).param("value", typeDeclaration.name()); format = ((DateTimeTypeDeclaration) typeDeclaration).format(); RamlTypeHelper.annotateDateWithPattern(jAnnotationUse, typeDeclaration.type(), format);
@Override public RamlInterpretationResult interpret(RamlRoot document, TypeDeclaration type, JCodeModel builderModel, boolean property) { RamlInterpretationResult result = new RamlInterpretationResult(type.required()); String arrayItem = arrayType.items().name(); if (!StringUtils.isEmpty(arrayItem) && arrayItem.endsWith("[]")) { arrayItem = arrayItem.substring(0, arrayItem.length() - 2);
@Override public boolean required() { return type.required(); }
@Override public RamlInterpretationResult interpret(RamlRoot document, TypeDeclaration type, JCodeModel builderModel, boolean property) { RamlInterpretationResult result = new RamlInterpretationResult(type.required()); result.setResolvedClass(builderModel.ref(SchemaHelper.mapDateFormat(type.type()))); return result; } }
@Override public String description() { return type.description() == null ? null : type.description().value(); }
private static List<V10GType> getParents(TypeDeclaration typeDeclaration, final V10TypeRegistry registry) { return Lists.transform(typeDeclaration.parentTypes(), new Function<TypeDeclaration, V10GType>() { @Nullable @Override public V10GType apply(@Nullable TypeDeclaration input) { return registry.fetchType(input); } }); }
/** * Safely get example from a type with null checks * * @param type * The RAML TypeDeclaration to check * @return The example if defined or null if empty */ public static String getExample(TypeDeclaration type) { if (type == null || type.example() == null) { return null; } else { return type.example().value(); } }
@Override public boolean apply(@Nullable TypeDeclaration input) { return name.equals(input.name()); } };
@Override public String getRawType() { return this.uriParameter.type(); } }