Search in sources :

Example 36 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project swagger-core by swagger-api.

the class Reader method parseMethod.

protected Operation parseMethod(Class<?> cls, Method method, List<Parameter> globalParameters, Produces methodProduces, Produces classProduces, Consumes methodConsumes, Consumes classConsumes, List<SecurityRequirement> classSecurityRequirements, Optional<io.swagger.v3.oas.models.ExternalDocumentation> classExternalDocs, Set<String> classTags, List<io.swagger.v3.oas.models.servers.Server> classServers, boolean isSubresource, RequestBody parentRequestBody, ApiResponses parentResponses, JsonView jsonViewAnnotation, io.swagger.v3.oas.annotations.responses.ApiResponse[] classResponses, AnnotatedMethod annotatedMethod) {
    Operation operation = new Operation();
    io.swagger.v3.oas.annotations.Operation apiOperation = ReflectionUtils.getAnnotation(method, io.swagger.v3.oas.annotations.Operation.class);
    List<io.swagger.v3.oas.annotations.security.SecurityRequirement> apiSecurity = ReflectionUtils.getRepeatableAnnotations(method, io.swagger.v3.oas.annotations.security.SecurityRequirement.class);
    List<io.swagger.v3.oas.annotations.callbacks.Callback> apiCallbacks = ReflectionUtils.getRepeatableAnnotations(method, io.swagger.v3.oas.annotations.callbacks.Callback.class);
    List<Server> apiServers = ReflectionUtils.getRepeatableAnnotations(method, Server.class);
    List<io.swagger.v3.oas.annotations.tags.Tag> apiTags = ReflectionUtils.getRepeatableAnnotations(method, io.swagger.v3.oas.annotations.tags.Tag.class);
    List<io.swagger.v3.oas.annotations.Parameter> apiParameters = ReflectionUtils.getRepeatableAnnotations(method, io.swagger.v3.oas.annotations.Parameter.class);
    List<io.swagger.v3.oas.annotations.responses.ApiResponse> apiResponses = ReflectionUtils.getRepeatableAnnotations(method, io.swagger.v3.oas.annotations.responses.ApiResponse.class);
    io.swagger.v3.oas.annotations.parameters.RequestBody apiRequestBody = ReflectionUtils.getAnnotation(method, io.swagger.v3.oas.annotations.parameters.RequestBody.class);
    ExternalDocumentation apiExternalDocumentation = ReflectionUtils.getAnnotation(method, ExternalDocumentation.class);
    // callbacks
    Map<String, Callback> callbacks = new LinkedHashMap<>();
    if (apiCallbacks != null) {
        for (io.swagger.v3.oas.annotations.callbacks.Callback methodCallback : apiCallbacks) {
            Map<String, Callback> currentCallbacks = getCallbacks(methodCallback, methodProduces, classProduces, methodConsumes, classConsumes, jsonViewAnnotation);
            callbacks.putAll(currentCallbacks);
        }
    }
    if (callbacks.size() > 0) {
        operation.setCallbacks(callbacks);
    }
    // security
    classSecurityRequirements.forEach(operation::addSecurityItem);
    if (apiSecurity != null) {
        Optional<List<SecurityRequirement>> requirementsObject = SecurityParser.getSecurityRequirements(apiSecurity.toArray(new io.swagger.v3.oas.annotations.security.SecurityRequirement[apiSecurity.size()]));
        if (requirementsObject.isPresent()) {
            requirementsObject.get().stream().filter(r -> operation.getSecurity() == null || !operation.getSecurity().contains(r)).forEach(operation::addSecurityItem);
        }
    }
    // servers
    if (classServers != null) {
        classServers.forEach(operation::addServersItem);
    }
    if (apiServers != null) {
        AnnotationsUtils.getServers(apiServers.toArray(new Server[apiServers.size()])).ifPresent(servers -> servers.forEach(operation::addServersItem));
    }
    // external docs
    AnnotationsUtils.getExternalDocumentation(apiExternalDocumentation).ifPresent(operation::setExternalDocs);
    // method tags
    if (apiTags != null) {
        apiTags.stream().filter(t -> operation.getTags() == null || (operation.getTags() != null && !operation.getTags().contains(t.name()))).map(io.swagger.v3.oas.annotations.tags.Tag::name).forEach(operation::addTagsItem);
        AnnotationsUtils.getTags(apiTags.toArray(new io.swagger.v3.oas.annotations.tags.Tag[apiTags.size()]), true).ifPresent(tags -> openApiTags.addAll(tags));
    }
    // parameters
    if (globalParameters != null) {
        for (Parameter globalParameter : globalParameters) {
            operation.addParametersItem(globalParameter);
        }
    }
    if (apiParameters != null) {
        getParametersListFromAnnotation(apiParameters.toArray(new io.swagger.v3.oas.annotations.Parameter[apiParameters.size()]), classConsumes, methodConsumes, operation, jsonViewAnnotation).ifPresent(p -> p.forEach(operation::addParametersItem));
    }
    // RequestBody in Method
    if (apiRequestBody != null && operation.getRequestBody() == null) {
        OperationParser.getRequestBody(apiRequestBody, classConsumes, methodConsumes, components, jsonViewAnnotation).ifPresent(operation::setRequestBody);
    }
    // operation id
    if (StringUtils.isBlank(operation.getOperationId())) {
        operation.setOperationId(getOperationId(method.getName()));
    }
    // classResponses
    if (classResponses != null && classResponses.length > 0) {
        OperationParser.getApiResponses(classResponses, classProduces, methodProduces, components, jsonViewAnnotation).ifPresent(responses -> {
            if (operation.getResponses() == null) {
                operation.setResponses(responses);
            } else {
                responses.forEach(operation.getResponses()::addApiResponse);
            }
        });
    }
    if (apiOperation != null) {
        setOperationObjectFromApiOperationAnnotation(operation, apiOperation, methodProduces, classProduces, methodConsumes, classConsumes, jsonViewAnnotation);
    }
    // apiResponses
    if (apiResponses != null && !apiResponses.isEmpty()) {
        OperationParser.getApiResponses(apiResponses.toArray(new io.swagger.v3.oas.annotations.responses.ApiResponse[apiResponses.size()]), classProduces, methodProduces, components, jsonViewAnnotation).ifPresent(responses -> {
            if (operation.getResponses() == null) {
                operation.setResponses(responses);
            } else {
                responses.forEach(operation.getResponses()::addApiResponse);
            }
        });
    }
    // class tags after tags defined as field of @Operation
    if (classTags != null) {
        classTags.stream().filter(t -> operation.getTags() == null || (operation.getTags() != null && !operation.getTags().contains(t))).forEach(operation::addTagsItem);
    }
    // external docs of class if not defined in annotation of method or as field of Operation annotation
    if (operation.getExternalDocs() == null) {
        classExternalDocs.ifPresent(operation::setExternalDocs);
    }
    // if subresource, merge parent requestBody
    if (isSubresource && parentRequestBody != null) {
        if (operation.getRequestBody() == null) {
            operation.requestBody(parentRequestBody);
        } else {
            Content content = operation.getRequestBody().getContent();
            if (content == null) {
                content = parentRequestBody.getContent();
                operation.getRequestBody().setContent(content);
            } else if (parentRequestBody.getContent() != null) {
                for (String parentMediaType : parentRequestBody.getContent().keySet()) {
                    if (content.get(parentMediaType) == null) {
                        content.addMediaType(parentMediaType, parentRequestBody.getContent().get(parentMediaType));
                    }
                }
            }
        }
    }
    // handle return type, add as response in case.
    Type returnType = method.getGenericReturnType();
    if (annotatedMethod != null && annotatedMethod.getType() != null) {
        returnType = annotatedMethod.getType();
    }
    final Class<?> subResource = getSubResourceWithJaxRsSubresourceLocatorSpecs(method);
    Schema returnTypeSchema = null;
    if (!shouldIgnoreClass(returnType.getTypeName()) && !method.getGenericReturnType().equals(subResource)) {
        ResolvedSchema resolvedSchema = ModelConverters.getInstance().resolveAsResolvedSchema(new AnnotatedType(returnType).resolveAsRef(true).jsonViewAnnotation(jsonViewAnnotation));
        if (resolvedSchema.schema != null) {
            returnTypeSchema = resolvedSchema.schema;
            Content content = new Content();
            MediaType mediaType = new MediaType().schema(returnTypeSchema);
            AnnotationsUtils.applyTypes(classProduces == null ? new String[0] : classProduces.value(), methodProduces == null ? new String[0] : methodProduces.value(), content, mediaType);
            if (operation.getResponses() == null) {
                operation.responses(new ApiResponses()._default(new ApiResponse().description(DEFAULT_DESCRIPTION).content(content)));
            }
            if (operation.getResponses().getDefault() != null && StringUtils.isBlank(operation.getResponses().getDefault().get$ref())) {
                if (operation.getResponses().getDefault().getContent() == null) {
                    operation.getResponses().getDefault().content(content);
                } else {
                    for (String key : operation.getResponses().getDefault().getContent().keySet()) {
                        if (operation.getResponses().getDefault().getContent().get(key).getSchema() == null) {
                            operation.getResponses().getDefault().getContent().get(key).setSchema(returnTypeSchema);
                        }
                    }
                }
            }
            Map<String, Schema> schemaMap = resolvedSchema.referencedSchemas;
            if (schemaMap != null) {
                schemaMap.forEach((key, schema) -> components.addSchemas(key, schema));
            }
        }
    }
    if (operation.getResponses() == null || operation.getResponses().isEmpty()) {
        Content content = resolveEmptyContent(classProduces, methodProduces);
        ApiResponse apiResponseObject = new ApiResponse().description(DEFAULT_DESCRIPTION).content(content);
        operation.setResponses(new ApiResponses()._default(apiResponseObject));
    }
    if (returnTypeSchema != null) {
        resolveResponseSchemaFromReturnType(operation, classResponses, returnTypeSchema, classProduces, methodProduces);
        if (apiResponses != null) {
            resolveResponseSchemaFromReturnType(operation, apiResponses.stream().toArray(io.swagger.v3.oas.annotations.responses.ApiResponse[]::new), returnTypeSchema, classProduces, methodProduces);
        }
    }
    return operation;
}
Also used : Arrays(java.util.Arrays) JsonView(com.fasterxml.jackson.annotation.JsonView) OpenAPIExtensions(io.swagger.v3.jaxrs2.ext.OpenAPIExtensions) Produces(javax.ws.rs.Produces) ResolvedSchema(io.swagger.v3.core.converter.ResolvedSchema) Parameter(io.swagger.v3.oas.models.parameters.Parameter) LoggerFactory(org.slf4j.LoggerFactory) OpenAPIConfiguration(io.swagger.v3.oas.integration.api.OpenAPIConfiguration) SecurityRequirement(io.swagger.v3.oas.models.security.SecurityRequirement) Operation(io.swagger.v3.oas.models.Operation) Application(javax.ws.rs.core.Application) StringUtils(org.apache.commons.lang3.StringUtils) AnnotationsUtils(io.swagger.v3.core.util.AnnotationsUtils) PathUtils(io.swagger.v3.core.util.PathUtils) Consumes(javax.ws.rs.Consumes) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory) Map(java.util.Map) OpenApiReader(io.swagger.v3.oas.integration.api.OpenApiReader) BeanDescription(com.fasterxml.jackson.databind.BeanDescription) Tag(io.swagger.v3.oas.models.tags.Tag) Method(java.lang.reflect.Method) ApiResponse(io.swagger.v3.oas.models.responses.ApiResponse) SecurityScheme(io.swagger.v3.oas.models.security.SecurityScheme) Content(io.swagger.v3.oas.models.media.Content) Hidden(io.swagger.v3.oas.annotations.Hidden) MediaType(io.swagger.v3.oas.models.media.MediaType) Set(java.util.Set) RequestBody(io.swagger.v3.oas.models.parameters.RequestBody) ReaderUtils(io.swagger.v3.jaxrs2.util.ReaderUtils) Paths(io.swagger.v3.oas.models.Paths) Collectors(java.util.stream.Collectors) AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) OpenAPIExtension(io.swagger.v3.jaxrs2.ext.OpenAPIExtension) ModelConverters(io.swagger.v3.core.converter.ModelConverters) List(java.util.List) OpenAPIDefinition(io.swagger.v3.oas.annotations.OpenAPIDefinition) Type(java.lang.reflect.Type) Annotation(java.lang.annotation.Annotation) Server(io.swagger.v3.oas.annotations.servers.Server) Optional(java.util.Optional) ObjectSchema(io.swagger.v3.oas.models.media.ObjectSchema) Json(io.swagger.v3.core.util.Json) ExternalDocumentation(io.swagger.v3.oas.annotations.ExternalDocumentation) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ParameterProcessor(io.swagger.v3.core.util.ParameterProcessor) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Schema(io.swagger.v3.oas.models.media.Schema) JavaType(com.fasterxml.jackson.databind.JavaType) AnnotatedMethod(com.fasterxml.jackson.databind.introspect.AnnotatedMethod) LinkedHashSet(java.util.LinkedHashSet) ApiResponses(io.swagger.v3.oas.models.responses.ApiResponses) Logger(org.slf4j.Logger) AnnotatedParameter(com.fasterxml.jackson.databind.introspect.AnnotatedParameter) Iterator(java.util.Iterator) PathItem(io.swagger.v3.oas.models.PathItem) ApplicationPath(javax.ws.rs.ApplicationPath) ContextUtils(io.swagger.v3.oas.integration.ContextUtils) Callback(io.swagger.v3.oas.models.callbacks.Callback) SwaggerConfiguration(io.swagger.v3.oas.integration.SwaggerConfiguration) ReflectionUtils(io.swagger.v3.core.util.ReflectionUtils) ParameterizedType(java.lang.reflect.ParameterizedType) Components(io.swagger.v3.oas.models.Components) Encoding(io.swagger.v3.oas.models.media.Encoding) Comparator(java.util.Comparator) Collections(java.util.Collections) Server(io.swagger.v3.oas.annotations.servers.Server) ResolvedSchema(io.swagger.v3.core.converter.ResolvedSchema) ObjectSchema(io.swagger.v3.oas.models.media.ObjectSchema) Schema(io.swagger.v3.oas.models.media.Schema) Operation(io.swagger.v3.oas.models.Operation) ApiResponse(io.swagger.v3.oas.models.responses.ApiResponse) LinkedHashMap(java.util.LinkedHashMap) ExternalDocumentation(io.swagger.v3.oas.annotations.ExternalDocumentation) MediaType(io.swagger.v3.oas.models.media.MediaType) List(java.util.List) ArrayList(java.util.ArrayList) ResolvedSchema(io.swagger.v3.core.converter.ResolvedSchema) ApiResponses(io.swagger.v3.oas.models.responses.ApiResponses) MediaType(io.swagger.v3.oas.models.media.MediaType) AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) Type(java.lang.reflect.Type) JavaType(com.fasterxml.jackson.databind.JavaType) ParameterizedType(java.lang.reflect.ParameterizedType) AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) Callback(io.swagger.v3.oas.models.callbacks.Callback) Content(io.swagger.v3.oas.models.media.Content) Parameter(io.swagger.v3.oas.models.parameters.Parameter) AnnotatedParameter(com.fasterxml.jackson.databind.introspect.AnnotatedParameter) Tag(io.swagger.v3.oas.models.tags.Tag) SecurityRequirement(io.swagger.v3.oas.models.security.SecurityRequirement)

Example 37 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project swagger-core by swagger-api.

the class Reader method processRequestBody.

protected void processRequestBody(Parameter requestBodyParameter, Operation operation, Consumes methodConsumes, Consumes classConsumes, List<Parameter> operationParameters, Annotation[] paramAnnotations, Type type, JsonView jsonViewAnnotation, Map<String, Encoding> encoding) {
    io.swagger.v3.oas.annotations.parameters.RequestBody requestBodyAnnotation = getRequestBody(Arrays.asList(paramAnnotations));
    if (requestBodyAnnotation != null) {
        Optional<RequestBody> optionalRequestBody = OperationParser.getRequestBody(requestBodyAnnotation, classConsumes, methodConsumes, components, jsonViewAnnotation);
        if (optionalRequestBody.isPresent()) {
            RequestBody requestBody = optionalRequestBody.get();
            if (StringUtils.isBlank(requestBody.get$ref()) && (requestBody.getContent() == null || requestBody.getContent().isEmpty())) {
                if (requestBodyParameter.getSchema() != null) {
                    Content content = processContent(requestBody.getContent(), requestBodyParameter.getSchema(), methodConsumes, classConsumes);
                    requestBody.setContent(content);
                }
            } else if (StringUtils.isBlank(requestBody.get$ref()) && requestBody.getContent() != null && !requestBody.getContent().isEmpty()) {
                if (requestBodyParameter.getSchema() != null) {
                    for (MediaType mediaType : requestBody.getContent().values()) {
                        if (mediaType.getSchema() == null) {
                            if (requestBodyParameter.getSchema() == null) {
                                mediaType.setSchema(new Schema());
                            } else {
                                mediaType.setSchema(requestBodyParameter.getSchema());
                            }
                        }
                        if (StringUtils.isBlank(mediaType.getSchema().getType())) {
                            mediaType.getSchema().setType(requestBodyParameter.getSchema().getType());
                        }
                    }
                }
            }
            operation.setRequestBody(requestBody);
        }
    } else {
        if (operation.getRequestBody() == null) {
            boolean isRequestBodyEmpty = true;
            RequestBody requestBody = new RequestBody();
            if (StringUtils.isNotBlank(requestBodyParameter.get$ref())) {
                requestBody.set$ref(requestBodyParameter.get$ref());
                isRequestBodyEmpty = false;
            }
            if (StringUtils.isNotBlank(requestBodyParameter.getDescription())) {
                requestBody.setDescription(requestBodyParameter.getDescription());
                isRequestBodyEmpty = false;
            }
            if (Boolean.TRUE.equals(requestBodyParameter.getRequired())) {
                requestBody.setRequired(requestBodyParameter.getRequired());
                isRequestBodyEmpty = false;
            }
            if (requestBodyParameter.getSchema() != null) {
                Content content = processContent(null, requestBodyParameter.getSchema(), methodConsumes, classConsumes);
                requestBody.setContent(content);
                isRequestBodyEmpty = false;
            }
            if (!isRequestBodyEmpty) {
                // requestBody.setExtensions(extensions);
                operation.setRequestBody(requestBody);
            }
        }
    }
    if (operation.getRequestBody() != null && operation.getRequestBody().getContent() != null && encoding != null && !encoding.isEmpty()) {
        Content content = operation.getRequestBody().getContent();
        for (String mediaKey : content.keySet()) {
            if (mediaKey.equals(javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED) || mediaKey.equals(javax.ws.rs.core.MediaType.MULTIPART_FORM_DATA)) {
                MediaType m = content.get(mediaKey);
                m.encoding(encoding);
            }
        }
    }
}
Also used : Content(io.swagger.v3.oas.models.media.Content) ResolvedSchema(io.swagger.v3.core.converter.ResolvedSchema) ObjectSchema(io.swagger.v3.oas.models.media.ObjectSchema) Schema(io.swagger.v3.oas.models.media.Schema) MediaType(io.swagger.v3.oas.models.media.MediaType) RequestBody(io.swagger.v3.oas.models.parameters.RequestBody)

Example 38 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.

the class LoggingConfigurationEndpoint method updateLoggerLevel.

/**
 * Looks up the logger in the logger factory,
 * and attempts to find the real logger instance
 * based on the underlying logging framework
 * and retrieve the logger object. Then, updates the level.
 * This functionality at this point is heavily dependant
 * on the log4j API.
 *
 * @param loggerName  the logger name
 * @param loggerLevel the logger level
 * @param additive    the additive nature of the logger
 */
@WriteOperation
@Operation(summary = "Update logger level for a logger name", parameters = { @Parameter(name = "loggerName", required = true), @Parameter(name = "loggerLevel", required = true), @Parameter(name = "additive") })
public void updateLoggerLevel(@Selector final String loggerName, final String loggerLevel, final boolean additive) {
    val loggerConfigs = getLoggerConfigurations();
    loggerConfigs.stream().filter(cfg -> cfg.getName().equals(loggerName)).forEachOrdered(cfg -> {
        cfg.setLevel(Level.getLevel(loggerLevel));
        cfg.setAdditive(additive);
    });
    this.loggerContext.updateLoggers();
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) Getter(lombok.Getter) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) SneakyThrows(lombok.SneakyThrows) LoggerContext(org.apache.logging.log4j.core.LoggerContext) LoggerFactory(org.slf4j.LoggerFactory) ToStringStyle(org.apache.commons.lang3.builder.ToStringStyle) Level(org.apache.logging.log4j.Level) HashMap(java.util.HashMap) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) StringUtils(org.apache.commons.lang3.StringUtils) InitializingBean(org.springframework.beans.factory.InitializingBean) HashSet(java.util.HashSet) Operation(io.swagger.v3.oas.annotations.Operation) Pair(org.apache.commons.lang3.tuple.Pair) Configurator(org.apache.logging.log4j.core.config.Configurator) Map(java.util.Map) Log4jLoggerFactory(org.apache.logging.slf4j.Log4jLoggerFactory) Resource(org.springframework.core.io.Resource) ResourceUtils(org.apereo.cas.util.ResourceUtils) Logger(org.slf4j.Logger) ResourceLoader(org.springframework.core.io.ResourceLoader) Endpoint(org.springframework.boot.actuate.endpoint.annotation.Endpoint) lombok.val(lombok.val) Set(java.util.Set) BaseCasActuatorEndpoint(org.apereo.cas.web.BaseCasActuatorEndpoint) Parameter(io.swagger.v3.oas.annotations.Parameter) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) Slf4j(lombok.extern.slf4j.Slf4j) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) Environment(org.springframework.core.env.Environment) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) Optional(java.util.Optional) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) ILoggerFactory(org.slf4j.ILoggerFactory) Selector(org.springframework.boot.actuate.endpoint.annotation.Selector) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) Operation(io.swagger.v3.oas.annotations.Operation)

Example 39 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.

the class AttributeConsentReportEndpoint method consentDecisions.

/**
 * Consent decisions collection.
 *
 * @param principal the principal
 * @return the collection
 */
@GetMapping(path = "{principal}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get consent decisions for principal", parameters = { @Parameter(name = "principal", required = true) })
public Collection<Map<String, Object>> consentDecisions(@PathVariable final String principal) {
    val result = new HashSet<Map<String, Object>>();
    LOGGER.debug("Fetching consent decisions for principal [{}]", principal);
    val consentDecisions = this.consentRepository.getObject().findConsentDecisions(principal);
    LOGGER.debug("Resolved consent decisions for principal [{}]: [{}]", principal, consentDecisions);
    consentDecisions.forEach(d -> {
        val map = new HashMap<String, Object>();
        map.put("decision", d);
        map.put("attributes", this.consentEngine.getObject().resolveConsentableAttributesFrom(d));
        result.add(map);
    });
    return result;
}
Also used : lombok.val(lombok.val) HashMap(java.util.HashMap) HashSet(java.util.HashSet) GetMapping(org.springframework.web.bind.annotation.GetMapping) Operation(io.swagger.v3.oas.annotations.Operation)

Example 40 with Parameter

use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.

the class SSOSamlIdPPostProfileHandlerEndpoint method produceGet.

/**
 * Produce response entity.
 *
 * @param request  the request
 * @param response the response
 * @return the response entity
 */
@GetMapping(produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody
@Operation(summary = "Produce SAML2 response entity", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "password", required = true), @Parameter(name = SamlProtocolConstants.PARAMETER_ENTITY_ID, required = true), @Parameter(name = "encrypt") })
public ResponseEntity<Object> produceGet(final HttpServletRequest request, final HttpServletResponse response) {
    val username = request.getParameter("username");
    val password = request.getParameter("password");
    val entityId = request.getParameter(SamlProtocolConstants.PARAMETER_ENTITY_ID);
    val encrypt = Boolean.parseBoolean(request.getParameter("encrypt"));
    return produce(request, response, username, password, entityId, encrypt);
}
Also used : lombok.val(lombok.val) GetMapping(org.springframework.web.bind.annotation.GetMapping) Operation(io.swagger.v3.oas.annotations.Operation) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)59 Parameter (io.swagger.v3.oas.models.parameters.Parameter)48 Test (org.testng.annotations.Test)39 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)33 Operation (io.swagger.v3.oas.models.Operation)28 lombok.val (lombok.val)26 OpenAPI (io.swagger.v3.oas.models.OpenAPI)20 Map (java.util.Map)18 ArrayList (java.util.ArrayList)16 ReadOperation (org.springframework.boot.actuate.endpoint.annotation.ReadOperation)15 OpenAPI3RequestValidationHandlerImpl (io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl)14 Test (org.junit.Test)14 PathItem (io.swagger.v3.oas.models.PathItem)13 QueryParameter (io.swagger.v3.oas.models.parameters.QueryParameter)13 StringUtils (org.apache.commons.lang3.StringUtils)13 Parameter (io.swagger.v3.oas.annotations.Parameter)12 StringSchema (io.swagger.v3.oas.models.media.StringSchema)12 LinkedHashMap (java.util.LinkedHashMap)12 RequestParameters (io.vertx.ext.web.api.RequestParameters)11 HashMap (java.util.HashMap)11