private void addPlainBodyArgument(final MimeType bodyMimeType, final JMethod method, final JDocComment javadoc) throws IOException { method.param(types.getRequestEntityClass(bodyMimeType), GENERIC_PAYLOAD_ARGUMENT_NAME); javadoc.addParam(GENERIC_PAYLOAD_ARGUMENT_NAME).add( getPrefixedExampleOrBlank(bodyMimeType.getExample())); }
private void addPlainBodyArgument(final MimeType bodyMimeType, final JMethod method, final JDocComment javadoc) throws IOException { method.param(types.getRequestEntityClass(bodyMimeType), GENERIC_PAYLOAD_ARGUMENT_NAME); javadoc.addParam(GENERIC_PAYLOAD_ARGUMENT_NAME).add( getPrefixedExampleOrBlank(bodyMimeType.getExample())); }
@Override public Collection<com.sap.cloud.yaas.servicegenerator.model.Response> transform(final Context context, final String responseCode, final Response response, final TransformationContext ctx) { final List<com.sap.cloud.yaas.servicegenerator.model.Response> result = new ArrayList<>(); if (response.getBody() != null) { for (final Map.Entry<String, MimeType> bodyEntry : response.getBody().entrySet()) { final com.sap.cloud.yaas.servicegenerator.model.Response target = com.sap.cloud.yaas.servicegenerator.model.Response .builder()// .code(responseCode)// .description(response.getDescription())// .bodyType(bodyEntry.getValue().getType())// .example(bodyEntry.getValue().getExample())// .build(); // headers // type result.add(target); } } return result; } }
public void exampleSchema(MimeType mimeType) { if (has(Validation.EXAMPLE)) { final String schema = mimeType.getSchema(); final String example = mimeType.getExample(); final SchemaValidator validator = findSchemaValidator(schemaValidators, MediaType.valueOf(mimeType.getType())); if (schema != null && example != null && validator != null) { validator.validate(new NamedReader(example, new Message("example").toString()), resolveSchema(raml, schema), violations, new Message("schema.example.mismatch", locator, example)); } } }
if ((responseMimeType != null) && (isNotBlank(responseMimeType.getExample()))) javadoc.add(EXAMPLE_PREFIX + responseMimeType.getExample()); responseBuilderMethod.param(types.getResponseEntityClass(responseMimeType), GENERIC_PAYLOAD_ARGUMENT_NAME); javadoc.addParam(GENERIC_PAYLOAD_ARGUMENT_NAME).add(defaultString(responseMimeType.getExample()));
@Override public void apply(MimeType body, ResourceClassBuilder resourceClassBuilder) { switch (byMimeType(body)) { case FORM: body.getFormParameters().forEach(resourceClassBuilder.applyFormParamsRule); break; case JSON: resourceClassBuilder.getApiClass().withMethod( bodyMethod() .withSchema(body.getCompiledSchema()) .withExample(body.getExample()) .withReqName(resourceClassBuilder.getReq().name()) .withInputPathForJsonGen(resourceClassBuilder.getCodegenConfig().getInputPath().getParent()) .withOutputPathForJsonGen(resourceClassBuilder.getCodegenConfig().getOutputPath()) .withPackageForJsonGen(resourceClassBuilder.getCodegenConfig().getBaseObjectsPackage() + addedObjectPackage(body.getCompiledSchema().toString())) .returns(resourceClassBuilder.getApiClass().name())); break; } }
if ((responseMimeType != null) && (isNotBlank(responseMimeType.getExample()))) javadoc.add(EXAMPLE_PREFIX + responseMimeType.getExample()); responseBuilderMethod.param(types.getResponseEntityClass(responseMimeType), GENERIC_PAYLOAD_ARGUMENT_NAME); javadoc.addParam(GENERIC_PAYLOAD_ARGUMENT_NAME).add(defaultString(responseMimeType.getExample()));
@Override public Parameter transform(final Context context, final MimeType source, final TransformationContext ctx) { if (StringUtils.isNotBlank(source.getSchema())) { final Dto argumentType; final JType type = ctx.getStore().getRamlMappingForSchema(source.getSchema()); if (type instanceof JDefinedClass) { argumentType = singleDtoTransformer.transform(context, (JDefinedClass) type, ctx.getNamespace()); } else if (type instanceof JClass) { argumentType = arrayDtoTransformer.transform(context, (JClass) type, ctx.getNamespace()); } else { argumentType = null; } return Parameter.builder()// .name("The schema " + source.getSchema())// .parameterType(ParameterType.BODY)// .qualifier(source.getSchema())// .example(source.getExample())// .type(argumentType)// .build(); } return null; }