本文整理匯總了Java中io.swagger.models.Path.set方法的典型用法代碼示例。如果您正苦於以下問題:Java Path.set方法的具體用法?Java Path.set怎麽用?Java Path.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.swagger.models.Path
的用法示例。
在下文中一共展示了Path.set方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: correctResponsesHavePaths
import io.swagger.models.Path; //導入方法依賴的package包/類
@Test
public void correctResponsesHavePaths() {
Response response = new Response();
Operation operation = new Operation();
operation.addResponse("200", response);
Path path = new Path();
path.set("get", operation);
Swagger swagger = new Swagger();
swagger.path("/base", path);
SwaggerUtils.correctResponses(swagger);
Assert.assertEquals("response of 200", response.getDescription());
}
示例2: getNewWildCardPathObject
import io.swagger.models.Path; //導入方法依賴的package包/類
private Path getNewWildCardPathObject(Path userDefinedWildCardPathObject) {
Preconditions.checkNotNull(
userDefinedWildCardPathObject, "userDefinedWildCardPathObject cannot be null");
Path path = new Path();
if (userDefinedWildCardPathObject.getGet() == null) {
path.set("get", constructReservedOperation("Get"));
}
if (userDefinedWildCardPathObject.getDelete() == null) {
path.set("delete", constructReservedOperation("Delete"));
}
if (userDefinedWildCardPathObject.getPatch() == null) {
path.set("patch", constructReservedOperation("Patch"));
}
if (userDefinedWildCardPathObject.getPost() == null) {
path.set("post", constructReservedOperation("Post"));
}
if (userDefinedWildCardPathObject.getPut() == null) {
path.set("put", constructReservedOperation("Put"));
}
return path;
}
示例3: path2UtilStats
import io.swagger.models.Path; //導入方法依賴的package包/類
private Path path2UtilStats(Parameter idParam) {
Path path = new Path();
if (idParam != null) {
path.setParameters(Collections.singletonList(paramId()));
}
io.swagger.models.Operation get = new io.swagger.models.Operation();
get.addTag(this.currentTag.getName());
get.setResponses(responseMap(
Operation.STATUS_CODE_OK, responseOk(template(ServiceStats.class)),
Operation.STATUS_CODE_NOT_FOUND, responseGenericError()));
path.set(Service.Action.GET.name().toLowerCase(), get);
io.swagger.models.Operation put = new io.swagger.models.Operation();
put.addTag(this.currentTag.getName());
put.setParameters(Arrays.asList(
paramNamedBody(template(ServiceStats.class)),
paramNamedBody(ServiceStats.ServiceStat.class)));
put.setResponses(responseMap(
Operation.STATUS_CODE_OK, responseOk(template(ServiceStats.class)),
Operation.STATUS_CODE_NOT_FOUND, responseGenericError()));
path.put(put);
io.swagger.models.Operation post = new io.swagger.models.Operation();
post.addTag(this.currentTag.getName());
post.setParameters(Collections.singletonList(paramBody(ServiceStat.class)));
post.setResponses(responseMap(
Operation.STATUS_CODE_OK, responseOk(template(ServiceStats.class)),
Operation.STATUS_CODE_NOT_FOUND, responseGenericError()));
path.post(post);
path.patch(post);
return path;
}
示例4: setUp
import io.swagger.models.Path; //導入方法依賴的package包/類
@Before
public void setUp() throws IOException {
swagger = createSwagger();
path = "/endpoint";
method = new Path();
method.set("get",new Operation());
}
示例5: read
import io.swagger.models.Path; //導入方法依賴的package包/類
private void read(ReaderContext context) {
for (Method method : context.getCls().getDeclaredMethods()) {
if (ReflectionUtils.isOverriddenMethod(method, context.getCls())) {
continue;
}
final Operation operation = new Operation();
final Type[] genericParameterTypes = method.getGenericParameterTypes();
final Annotation[][] paramAnnotations = method.getParameterAnnotations();
ControllerReaderExtension extension = new ControllerReaderExtension();
String methodPath = "index".equals(method.getName()) ? "" : "/" + method.getName();
String operationPath = JbootControllerManager.me().getPathByController((Class<? extends Controller>) context.getCls()) + methodPath;
String httpMethod = extension.getHttpMethod(context, method);
if (operationPath == null || httpMethod == null) {
continue;
}
if (extension.isReadable(context)) {
extension.setDeprecated(operation, method);
extension.applyConsumes(context, operation, method);
extension.applyProduces(context, operation, method);
extension.applyOperationId(operation, method);
extension.applySummary(operation, method);
extension.applyDescription(operation, method);
extension.applySchemes(context, operation, method);
extension.applySecurityRequirements(context, operation, method);
extension.applyTags(context, operation, method);
extension.applyResponses(swagger, context, operation, method);
extension.applyImplicitParameters(swagger, context, operation, method);
extension.applyExtensions(context, operation, method);
for (int i = 0; i < genericParameterTypes.length; i++) {
extension.applyParameters(httpMethod, context, operation, paramAnnotations[i]);
}
if ("post".equalsIgnoreCase(httpMethod) && operation.getConsumes() == null) {
operation.addConsumes("application/x-www-form-urlencoded");
}
}
if (operation.getResponses() == null) {
operation.defaultResponse(new Response().description("successful operation"));
}
final Map<String, String> regexMap = new HashMap<String, String>();
final String parsedPath = PathUtils.parsePath(operationPath, regexMap);
Path path = swagger.getPath(parsedPath);
if (path == null) {
path = new SwaggerPath();
swagger.path(parsedPath, path);
}
path.set(httpMethod.toLowerCase(), operation);
}
}