本文整理汇总了Java中org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolverFactory类的典型用法代码示例。如果您正苦于以下问题:Java RestDocumentationContextPlaceholderResolverFactory类的具体用法?Java RestDocumentationContextPlaceholderResolverFactory怎么用?Java RestDocumentationContextPlaceholderResolverFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RestDocumentationContextPlaceholderResolverFactory类属于org.springframework.restdocs.snippet包,在下文中一共展示了RestDocumentationContextPlaceholderResolverFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolverFactory; //导入依赖的package包/类
public Operation build() {
if (this.attributes.get(TemplateEngine.class.getName()) == null) {
Map<String, Object> templateContext = new HashMap<>();
templateContext.put("tableCellContent",
new AsciidoctorTableCellContentLambda());
this.attributes.put(TemplateEngine.class.getName(),
new MustacheTemplateEngine(
new StandardTemplateResourceResolver(this.templateFormat),
Mustache.compiler().escapeHTML(false), templateContext));
}
RestDocumentationContext context = createContext();
this.attributes.put(RestDocumentationContext.class.getName(), context);
this.attributes.put(WriterResolver.class.getName(),
new StandardWriterResolver(
new RestDocumentationContextPlaceholderResolverFactory(), "UTF-8",
this.templateFormat));
return new StandardOperation(this.name,
(this.requestBuilder == null
? new OperationRequestBuilder("http://localhost/").buildRequest()
: this.requestBuilder.buildRequest()),
this.responseBuilder == null
? new OperationResponseBuilder().buildResponse()
: this.responseBuilder.buildResponse(),
this.attributes);
}
示例2: build
import org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolverFactory; //导入依赖的package包/类
public Operation build() {
if (this.attributes.get(TemplateEngine.class.getName()) == null) {
Map<String, Object> templateContext = new HashMap<>();
templateContext.put("tableCellContent",
new AsciidoctorTableCellContentLambda());
this.attributes.put(TemplateEngine.class.getName(),
new MustacheTemplateEngine(
new StandardTemplateResourceResolver(this.templateFormat),
Mustache.compiler().escapeHTML(false), templateContext));
}
RestDocumentationContext context = createContext();
this.attributes.put(RestDocumentationContext.class.getName(), context);
this.attributes.put(WriterResolver.class.getName(),
new StandardWriterResolver(
new RestDocumentationContextPlaceholderResolverFactory(), "UTF-8",
this.templateFormat));
return new StandardOperation(this.name,
(this.requestBuilder == null
? new OperationRequestBuilder("http://localhost/").buildRequest()
: this.requestBuilder.buildRequest()),
this.responseBuilder.buildResponse(), this.attributes);
}
示例3: documentSnippet
import org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolverFactory; //导入依赖的package包/类
private void documentSnippet(Operation operation) throws IOException {
WriterResolver writerResolver = new StandardWriterResolver(new RestDocumentationContextPlaceholderResolverFactory(), DEFAULT_SNIPPET_ENCODING, new RamlTemplateFormat());
try (Writer writer = writerResolver.resolve(operation.getName(), SNIPPET_NAME,
(RestDocumentationContext) operation.getAttributes().get(RestDocumentationContext.class.getName()))) {
Map<String, Object> model = createModel(operation);
TemplateEngine templateEngine = new MustacheTemplateEngine(new StandardTemplateResourceResolver(new RamlTemplateFormat()));
writer.append(templateEngine.compileTemplate(SNIPPET_NAME).render(model));
}
}
示例4: document
import org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolverFactory; //导入依赖的package包/类
@Override
public void document(Operation operation) throws IOException {
RestDocumentationContext context = (RestDocumentationContext) operation.getAttributes()
.get(RestDocumentationContext.class.getName());
WriterResolver writerResolver = new StandardWriterResolver(
new RestDocumentationContextPlaceholderResolverFactory(), "UTF-8", TEMPLATE_FORMAT);
try (Writer writer = writerResolver.resolve(operation.getName(), SNIPPET_NAME, context)) {
writer.append(toJsonString(operation));
}
}