本文整理汇总了Java中org.raml.model.Response类的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于org.raml.model包,在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: exampleResponse
import org.raml.model.Response; //导入依赖的package包/类
@Override
public EndpointRoute exampleResponse(HttpResponseStatus status, Object model, String description) {
Response response = new Response();
response.setDescription(description);
HashMap<String, MimeType> map = new HashMap<>();
response.setBody(map);
MimeType mimeType = new MimeType();
if (model instanceof RestModel) {
String json = JsonUtil.toJson(model);
mimeType.setExample(json);
mimeType.setSchema(JsonUtil.getJsonSchema(model.getClass()));
map.put("application/json", mimeType);
} else {
mimeType.setExample(model.toString());
map.put("text/plain", mimeType);
}
exampleResponses.put(status.code(), response);
exampleResponseClasses.put(status.code(), model.getClass());
return this;
}
开发者ID:gentics,项目名称:mesh,代码行数:24,代码来源:EndpointImpl.java
示例2: testConvertResponse
import org.raml.model.Response; //导入依赖的package包/类
@Test
public void testConvertResponse() {
Response source = new Response();
source.setDescription("responseDescription");
Map<String, Header> headers = new HashMap<>();
headers.put("testHeader", new Header());
Map<String, MimeType> body = new HashMap<>();
body.put("testBody", new MimeType());
source.setHeaders(headers);
source.setBody(body);
ch.alv.components.web.api.config.Response result = converter.convertResponse(source);
assertEquals(source.getDescription(), result.getDescription());
assertEquals(source.getBody().size(), result.getBody().size());
assertEquals(source.getHeaders().size(), result.getHeaders().size());
assertNull(converter.convertResponse(null));
}
开发者ID:alv-ch,项目名称:alv-ch-java,代码行数:19,代码来源:RamlConverterTest.java
示例3: getProperty
import org.raml.model.Response; //导入依赖的package包/类
@Override
public Object getProperty(Interpreter interp, ST self, Object o, Object property, String propertyName) throws STNoSuchPropertyException {
final Response r = (Response) o;
switch (propertyName) {
case "body":
return r.getBody() == null ? null : new TreeMap<>(r.getBody());
case "headers":
return new TreeMap<>(r.getHeaders());
default:
return super.getProperty(interp, self, o, property, propertyName);
}
}
开发者ID:nidi3,项目名称:raml-doc,代码行数:13,代码来源:ResponseAdaptor.java
示例4: createMethodResponses
import org.raml.model.Response; //导入依赖的package包/类
private void createMethodResponses(RestApi api, Method method, Map<String, Response> responses, boolean update) {
for (Map.Entry<String, Response> entry : responses.entrySet()) {
createMethodResponse(api, method, entry.getKey(), entry.getValue(), update);
}
if (update) {
cleanupMethodResponses(method, responses);
}
}
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:10,代码来源:ApiGatewaySdkRamlApiImporter.java
示例5: cleanupMethodResponses
import org.raml.model.Response; //导入依赖的package包/类
private void cleanupMethodResponses(Method method, Map<String, Response> responses) {
method.getMethodResponses().entrySet().forEach(entry -> {
if (!responses.containsKey(entry.getKey())) {
entry.getValue().deleteMethodResponse();
}
});
}
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:8,代码来源:ApiGatewaySdkRamlApiImporter.java
示例6: validate
import org.raml.model.Response; //导入依赖的package包/类
@Override
public ValidationErrors validate() {
ValidationErrors errors = new ValidationErrors();
if (!expectation.hasValidAction())
throw new NoValidActionException(expectation);
Integer statusCode = expectation.getResponseStatusCode();
MediaType contentType = expectation.getResponseContentType();
Optional<Response> response = expectation.getResponse();
if (!response.isPresent()) {
errors.addMessage("[ response ] [ %d ] [ %s ] No response body specification exists.", statusCode, contentType);
return errors;
}
Optional<BodySpecification> specification = expectation.getResponseBodySpecification();
Optional<String> responseBody = expectation.getResponseBody();
if (!specification.isPresent() && responseBody.isPresent()) {
errors.addMessage("[ response ] [ %d ] [ %s ] No response body specification exists for this content type. Acceptable content types are [ %s ].", statusCode, contentType, getAllowedContentTypes(response.get().getBody()));
return errors;
}
if (!responseBody.isPresent()) {
errors.addMessage("[ response ] [ %d ] [ %s ] Has an expected response body but none returned.", statusCode, contentType);
return errors;
}
errors.combineWith(specification.get().validate(responseBody.get()));
return errors;
}
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:35,代码来源:ResponseBodyValidator.java
示例7: getProperty
import org.raml.model.Response; //导入依赖的package包/类
@Override
public synchronized Object getProperty(Interpreter anInter, ST aSt,
Object anObject, Object aProperty, String aName)
throws STNoSuchPropertyException {
Response oResponse=(Response)anObject;
if(aName.equals("body")) {
if(oResponse.getBody()==null || oResponse.getBody().size()==0) {
Map<String, MimeType> oMap=oResponse.getBody()==null?new HashMap<String, MimeType>():oResponse.getBody();
oMap.put("*/*", new MimeType("*/*"));
oResponse.setBody(oMap);
}
}
return super.getProperty(anInter, aSt, anObject, aProperty, aName);
}
开发者ID:pagesjaunes,项目名称:raml-codegen,代码行数:15,代码来源:ResponseAdaptator.java
示例8: render
import org.raml.model.Response; //导入依赖的package包/类
@Override
public Bundle render(Raml aRoot, Map<String, String> someOpts) {
STGroup stg = new STGroupFile(stgFile);
stg.registerModelAdaptor(Resource.class, new ResourceAdaptator());
stg.registerModelAdaptor(Raml.class, new RamlAdaptator());
stg.registerModelAdaptor(Action.class, new ActionAdaptator(aRoot));
stg.registerModelAdaptor(Response.class, new ResponseAdaptator());
stg.registerModelAdaptor(MimeType.class, new MimeTypeAdaptator());
Map<String, String> oOpts=new HashMap<String, String>(someOpts);
oOpts.put("title", Utils.cleanString(aRoot.getTitle()));
if(someOpts.get("baseUri")!=null) {
aRoot.setBaseUri(someOpts.get("baseUri"));
}
aRoot.setBaseUri(Utils.resolve(aRoot.getBaseUri(), "version", aRoot.getVersion()));
Bundle oBundle=null;
ST oRootPath=getST(stg,"rootPath", aRoot, oOpts);
if(oRootPath!=null) {
oBundle=new Bundle(oRootPath.render());
} else {
oBundle=new Bundle(someOpts.get(Generator.GENERATED_PATH));
}
for(String oName:rootTemplateNames) {
ST oContent = getST(stg,oName, aRoot, oOpts);
ST oFileName = getST(stg,oName+"_file", aRoot,oOpts);
oBundle.addItem(oFileName.render(), oContent.render());
}
return oBundle;
}
开发者ID:pagesjaunes,项目名称:raml-codegen,代码行数:29,代码来源:StringTemplateRenderer.java
示例9: convertResponses
import org.raml.model.Response; //导入依赖的package包/类
public List<ch.alv.components.web.api.config.Response> convertResponses(Map<String, Response> source) {
List<ch.alv.components.web.api.config.Response> list = new ArrayList<>();
if (source.isEmpty()) {
return list;
}
for (String key : source.keySet()) {
list.add(convertResponse(source.get(key)));
}
return list;
}
开发者ID:alv-ch,项目名称:alv-ch-java,代码行数:11,代码来源:RamlConverter.java
示例10: convertResponse
import org.raml.model.Response; //导入依赖的package包/类
public ch.alv.components.web.api.config.Response convertResponse(Response source) {
if (source == null) {
return null;
}
ch.alv.components.web.api.config.Response target = new ch.alv.components.web.api.config.Response();
target.setDescription(convertDescription(source.getDescription()));
target.setBody(convertMimeTypes(source.getBody()));
target.setHeaders(convertHeaders(source.getHeaders()));
return target;
}
开发者ID:alv-ch,项目名称:alv-ch-java,代码行数:11,代码来源:RamlConverter.java
示例11: testConvertResponses
import org.raml.model.Response; //导入依赖的package包/类
@Test
public void testConvertResponses() {
Map<String, Response> source = new HashMap<>();
source.put("testResponse", new Response());
List<ch.alv.components.web.api.config.Response> result = converter.convertResponses(source);
assertEquals(1, result.size());
assertEquals(0, converter.convertResponses(new HashMap<String, Response>()).size());
}
开发者ID:alv-ch,项目名称:alv-ch-java,代码行数:9,代码来源:RamlConverterTest.java
示例12: getResponseForAction
import org.raml.model.Response; //导入依赖的package包/类
protected Response getResponseForAction(Action action, String status) {
for (Map.Entry<String, Response> response: action.getResponses().entrySet()) {
if (response.getKey().equals(status)) {
return response.getValue();
}
}
throw new IllegalArgumentException(format("no response found for status %s in action %s", status, action));
}
开发者ID:adrobisch,项目名称:raml-converter,代码行数:9,代码来源:Raml2HtmlRenderer.java
示例13: getExampleResponses
import org.raml.model.Response; //导入依赖的package包/类
@Override
public Map<Integer, Response> getExampleResponses() {
return exampleResponses;
}
开发者ID:gentics,项目名称:mesh,代码行数:5,代码来源:EndpointImpl.java
示例14: createRamlResponse
import org.raml.model.Response; //导入依赖的package包/类
@Override
public RamlResponse createRamlResponse() {
return createRamlResponse(new Response());
}
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:5,代码来源:RJP08V1RamlModelFactory.java
示例15: extractResponse
import org.raml.model.Response; //导入依赖的package包/类
Response extractResponse(RamlResponse ramlResponse) {
return ((RJP08V1RamlResponse)ramlResponse).getResponse();
}
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:4,代码来源:RJP08V1RamlModelFactory.java
示例16: RJP08V1RamlResponse
import org.raml.model.Response; //导入依赖的package包/类
public RJP08V1RamlResponse(Response response) {
this.response = response;
}
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:4,代码来源:RJP08V1RamlResponse.java
示例17: getResponse
import org.raml.model.Response; //导入依赖的package包/类
public Response getResponse() {
return response;
}
开发者ID:pagesjaunes,项目名称:raml-codegen,代码行数:4,代码来源:ActionAdaptator.java
示例18: ResponseWrapper
import org.raml.model.Response; //导入依赖的package包/类
private ResponseWrapper(Action anAction, Response aResponse, String aStatus) {
response=aResponse;
action=anAction;
status=aStatus;
}
开发者ID:pagesjaunes,项目名称:raml-codegen,代码行数:6,代码来源:ActionAdaptator.java
示例19: ResponseContext
import org.raml.model.Response; //导入依赖的package包/类
public ResponseContext(Response response) {
this.response = response;
}
开发者ID:adrobisch,项目名称:raml-converter,代码行数:4,代码来源:ResponseContext.java
示例20: getExampleResponses
import org.raml.model.Response; //导入依赖的package包/类
/**
* Return the map of example responses. The map contains examples per http status code.
*
* @return
*/
Map<Integer, Response> getExampleResponses();
开发者ID:gentics,项目名称:mesh,代码行数:7,代码来源:EndpointRoute.java
注:本文中的org.raml.model.Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论