本文整理匯總了Java中io.swagger.models.Operation.defaultResponse方法的典型用法代碼示例。如果您正苦於以下問題:Java Operation.defaultResponse方法的具體用法?Java Operation.defaultResponse怎麽用?Java Operation.defaultResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.swagger.models.Operation
的用法示例。
在下文中一共展示了Operation.defaultResponse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: read
import io.swagger.models.Operation; //導入方法依賴的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);
}
}