Java Code Examples for io.swagger.models.Operation#setSummary()

The following examples show how to use io.swagger.models.Operation#setSummary() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OperationsTransformer.java    From spring-openapi with MIT License 6 votes vote down vote up
private Operation mapOperation(String operationName, HttpMethod httpMethod, Method method, String[] produces, String[] consumes, String controllerClassName) {
	Operation operation = new Operation();
	operation.setOperationId(getOperationId(operationName, method, httpMethod));
	operation.setSummary(StringUtils.isBlank(operationName) ? operationName : method.getName());
	operation.setTags(singletonList(classNameToTag(controllerClassName)));

	operation.setResponses(createApiResponses(method));
	operation.setParameters(transformParameters(method));
	if (isNotEmpty(consumes)) {
		operation.setConsumes(asList(consumes));
	}
	if (isNotEmpty(produces)) {
		operation.setProduces(asList(produces));
	}

	if (isHttpMethodWithRequestBody(httpMethod)) {
		io.swagger.models.parameters.Parameter requestBody = createRequestBody(method, getFirstFromArray(consumes));
		if (requestBody != null) {
			operation.getParameters().add(requestBody);
		}
	}

	applyAnnotationsForOperation(operation, method.getAnnotations());
	operationInterceptors.forEach(interceptor -> interceptor.intercept(method, operation));
	return operation;
}
 
Example 2
Source File: ApiOperationProcessor.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
public void process(SwaggerGenerator swaggerGenerator,
    OperationGenerator operationGenerator, ApiOperation apiOperationAnnotation) {
  Operation operation = operationGenerator.getOperation();

  operationGenerator.setHttpMethod(apiOperationAnnotation.httpMethod());

  if (!StringUtils.isEmpty(apiOperationAnnotation.value())) {
    operation.setSummary(apiOperationAnnotation.value());
  }

  if (!StringUtils.isEmpty(apiOperationAnnotation.notes())) {
    operation.setDescription(apiOperationAnnotation.notes());
  }

  operation.setOperationId(apiOperationAnnotation.nickname());
  operation.getVendorExtensions().putAll(BaseReaderUtils.parseExtensions(apiOperationAnnotation.extensions()));

  convertTags(apiOperationAnnotation.tags(), operation);
  SwaggerUtils.setCommaConsumes(operation, apiOperationAnnotation.consumes());
  SwaggerUtils.setCommaProduces(operation, apiOperationAnnotation.produces());
  convertProtocols(apiOperationAnnotation.protocols(), operation);
  AnnotationUtils.addResponse(swaggerGenerator.getSwagger(),
      operation,
      apiOperationAnnotation);

  // responseReference未解析
  // hidden未解析
  // authorizations未解析
}
 
Example 3
Source File: TestOperationInterceptor.java    From spring-openapi with MIT License 4 votes vote down vote up
@Override
public void intercept(Method method, Operation transformedOperation) {
	transformedOperation.setSummary("Interceptor summary");
}