org.apache.flink.shaded.jackson2.com.fasterxml.jackson.module.jsonSchema.JsonSchema Java Examples

The following examples show how to use org.apache.flink.shaded.jackson2.com.fasterxml.jackson.module.jsonSchema.JsonSchema. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestAPIDocGenerator.java    From flink with Apache License 2.0 6 votes vote down vote up
private static String createMessageHtmlEntry(Class<?> messageClass, @Nullable Class<?> nestedAsyncOperationResultClass, Class<?> emptyMessageClass) {
	JsonSchema schema = generateSchema(messageClass);

	if (nestedAsyncOperationResultClass != null) {
		JsonSchema innerSchema = generateSchema(nestedAsyncOperationResultClass);
		schema.asObjectSchema().getProperties().put(AsynchronousOperationResult.FIELD_NAME_OPERATION, innerSchema);
	}

	String json;
	if (messageClass == emptyMessageClass) {
		json = "{}";
	} else {
		try {
			json = mapper.writerWithDefaultPrettyPrinter()
				.writeValueAsString(schema);
		} catch (JsonProcessingException e) {
			LOG.error("Failed to write message schema for class {}.", messageClass.getCanonicalName(), e);
			throw new RuntimeException("Failed to write message schema for class " + messageClass.getCanonicalName() + ".", e);
		}
	}

	return json;
}
 
Example #2
Source File: RestAPIDocGenerator.java    From flink with Apache License 2.0 5 votes vote down vote up
private static JsonSchema generateSchema(Class<?> messageClass) {
	try {
		return schemaGen.generateSchema(messageClass);
	} catch (JsonProcessingException e) {
		LOG.error("Failed to generate message schema for class {}.", messageClass, e);
		throw new RuntimeException("Failed to generate message schema for class " + messageClass.getCanonicalName() + ".", e);
	}
}