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

The following examples show how to use io.swagger.models.Operation#setParameters() . 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: OperationGenerator.java    From yang2swagger with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Default empty operation that defines error response only
 * @return basic operation with 400 response pre-defined
 */
protected Operation defaultOperation() {
    final Operation operation = new io.swagger.models.Operation();
    operation.response(400, new Response().description("Internal error"));
    operation.setParameters(path.params());
    return operation;
}
 
Example 3
Source File: PostOperationGenerator.java    From yang2swagger with Eclipse Public License 1.0 4 votes vote down vote up
private Operation listOperation() {
    Operation listOper = defaultOperation();
    listOper.setParameters(path.listParams());
    return listOper;
}