當前位置: 首頁>>代碼示例>>Java>>正文


Java Operation.getResponses方法代碼示例

本文整理匯總了Java中io.swagger.models.Operation.getResponses方法的典型用法代碼示例。如果您正苦於以下問題:Java Operation.getResponses方法的具體用法?Java Operation.getResponses怎麽用?Java Operation.getResponses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.swagger.models.Operation的用法示例。


在下文中一共展示了Operation.getResponses方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testBase

import io.swagger.models.Operation; //導入方法依賴的package包/類
private void testBase(Path path) {
  Assert.assertEquals(1, path.getOperations().size());

  Operation operation = path.getGet();

  Assert.assertEquals("summary", operation.getSummary());
  Assert.assertEquals("notes", operation.getDescription());
  Assert.assertEquals(Arrays.asList("tag1", "tag2"), operation.getTags());
  Assert.assertEquals(Arrays.asList("application/json"), operation.getProduces());
  Assert.assertEquals(Arrays.asList("application/json"), operation.getConsumes());
  Assert.assertEquals(Arrays.asList(Scheme.HTTP, Scheme.HTTPS), operation.getSchemes());

  Map<String, Response> responseMap = operation.getResponses();
  Assert.assertEquals(2, responseMap.size());

  Response response = responseMap.get(SwaggerConst.SUCCESS_KEY);
  Assert.assertNotNull(response);
  Assert.assertEquals(null, response.getSchema());

  response = responseMap.get("202");
  Assert.assertNotNull(response);
  Assert.assertEquals(null, response.getSchema());

  Assert.assertEquals(1, response.getHeaders().size());
  Assert.assertEquals("integer", response.getHeaders().get("h1").getType());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:27,代碼來源:TestApiOperation.java

示例2: decorateOperation

import io.swagger.models.Operation; //導入方法依賴的package包/類
@Override
public void decorateOperation(Operation operation, Method method, Iterator<SwaggerExtension> chain) {
	super.decorateOperation(operation, method, chain);

	// responses property set
	final Map<String, Response> responses = operation.getResponses();
	if (responses != null) {
		getResponsePropertySet(method).ifPresent(aps -> {
			PropertySet<?> propertySet = PropertySetRefIntrospector.get().getPropertySet(aps);
			if (propertySet != null) {
				ApiPropertySetModel psm = getResponsePropertySetModel(method).orElse(null);
				final Property propertyBoxProperty = buildPropertyBoxProperty(propertySet, true,
						(psm != null) ? AnnotationUtils.getStringValue(psm.value()) : null,
						(psm != null) ? AnnotationUtils.getStringValue(psm.description()) : null,
						(psm != null) ? AnnotationUtils.getStringValue(psm.reference()) : null,
						SwaggerContext.getSwagger());

				// responses
				for (Response response : responses.values()) {
					ArrayProperty ap = isPropertyBoxArrayPropertyType(response.getSchema());
					if (ap != null) {
						ap.items(propertyBoxProperty);
					} else if (isPropertyBoxPropertyType(response.getSchema())) {
						response.schema(propertyBoxProperty);
					}
				}
			}
		});
	}
}
 
開發者ID:holon-platform,項目名稱:holon-jaxrs,代碼行數:31,代碼來源:PropertyBoxSwaggerExtension.java

示例3: mergeOperationResponse

import io.swagger.models.Operation; //導入方法依賴的package包/類
private Map<String, Response> mergeOperationResponse(Operation target, Operation source) {
	Map<String, Response> mergedResponse = target.getResponses();
	
	for (Entry<String, Response> entry : source.getResponses().entrySet()) {
		mergedResponse.put(entry.getKey(), entry.getValue());
	}
	
	return mergedResponse;
}
 
開發者ID:pegasystems,項目名稱:api2swagger,代碼行數:10,代碼來源:SwaggerUpdater.java

示例4: 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);
        }
    }
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:61,代碼來源:Reader.java


注:本文中的io.swagger.models.Operation.getResponses方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。