JacksonResponseFieldSnippet extends AbstractJacksonFieldSnippet { public JacksonResponseFieldSnippet responseBodyAsType(Type responseBodyType) { return new JacksonResponseFieldSnippet(responseBodyType, failOnUndocumentedFields); } JacksonResponseFieldSnippet();  JacksonResponseFieldSnippet(Type responseBodyType, boolean failOnUndocumentedFields); JacksonResponseFieldSnippet responseBodyAsType(Type responseBodyType); JacksonResponseFieldSnippet failOnUndocumentedFields(boolean failOnUndocumentedFields); @Override String getHeaderKey(Operation operation); static final Set<String> SPRING_HATEOAS_CLASSES; static final String REACTOR_MONO_CLASS; static final String REACTOR_FLUX_CLASS; }
@Test public void exactResponseType() throws Exception { HandlerMethod handlerMethod = createHandlerMethod("processItem"); mockFieldComment(ProcessingResponse.class, "output", "An output"); new JacksonResponseFieldSnippet().responseBodyAsType(ProcessingResponse.class) .document(operationBuilder .attribute(HandlerMethod.class.getName(), handlerMethod) .attribute(ObjectMapper.class.getName(), mapper) .attribute(JavadocReader.class.getName(), javadocReader) .attribute(ConstraintReader.class.getName(), constraintReader) .build()); assertThat(this.generatedSnippets.snippet(AUTO_RESPONSE_FIELDS)).is( tableWithHeader("Path", "Type", "Optional", "Description") .row("output", "String", "true", "An output.")); }
@Test public void escaping() throws Exception { HandlerMethod handlerMethod = createHandlerMethod("processItem"); mockFieldComment(ProcessingResponse.class, "output", "An output | result"); new JacksonResponseFieldSnippet().responseBodyAsType(ProcessingResponse.class) .document(operationBuilder .attribute(HandlerMethod.class.getName(), handlerMethod) .attribute(ObjectMapper.class.getName(), mapper) .attribute(JavadocReader.class.getName(), javadocReader) .attribute(ConstraintReader.class.getName(), constraintReader) .build()); assertThat(this.generatedSnippets.snippet(AUTO_RESPONSE_FIELDS)).is( tableWithHeader("Path", "Type", "Optional", "Description") .row("output", "String", "true", "An output \\| result.")); }