Search in sources :

Example 41 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse in project swagger-core by swagger-api.

the class SimpleBuilderTest method testBuilder.

@Test
public void testBuilder() throws Exception {
    // basic metadata
    OpenAPI oai = new OpenAPI().info(new Info().contact(new Contact().email("tony@eatbacon.org").name("Tony the Tam").url("https://foo.bar"))).externalDocs(new ExternalDocumentation().description("read more here").url("http://swagger.io")).addTagsItem(new Tag().name("funky dunky").description("all about neat things")).extensions(new HashMap<String, Object>() {

        {
            put("x-fancy-extension", "something");
        }
    });
    Map<String, Schema> schemas = new HashMap<>();
    schemas.put("StringSchema", new StringSchema().description("simple string schema").minLength(3).maxLength(100).example("it works"));
    schemas.put("IntegerSchema", new IntegerSchema().description("simple integer schema").multipleOf(new BigDecimal(3)).minimum(new BigDecimal(6)));
    oai.components(new Components().schemas(schemas));
    schemas.put("Address", new Schema().description("address object").addProperties("street", new StringSchema().description("the street number")).addProperties("city", new StringSchema().description("city")).addProperties("state", new StringSchema().description("state").minLength(2).maxLength(2)).addProperties("zip", new StringSchema().description("zip code").pattern("^\\d{5}(?:[-\\s]\\d{4})?$").minLength(2).maxLength(2)).addProperties("country", new StringSchema()._enum(new ArrayList<String>() {

        {
            this.add("US");
        }
    })).description("2-digit country code").minLength(2).maxLength(2));
    oai.paths(new Paths().addPathItem("/foo", new PathItem().description("the foo path").get(new Operation().addParametersItem(new QueryParameter().description("Records to skip").required(false).schema(new IntegerSchema())).responses(new ApiResponses().addApiResponse("200", new ApiResponse().description("it worked").content(new Content().addMediaType("application/json", new MediaType().schema(new Schema().$ref("#/components/schemas/Address")))).addLink("funky", new Link().operationId("getFunky")))))));
    System.out.println(writeJson(oai));
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) HashMap(java.util.HashMap) Schema(io.swagger.v3.oas.models.media.Schema) IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) StringSchema(io.swagger.v3.oas.models.media.StringSchema) ArrayList(java.util.ArrayList) Operation(io.swagger.v3.oas.models.Operation) ApiResponse(io.swagger.v3.oas.models.responses.ApiResponse) Components(io.swagger.v3.oas.models.Components) PathItem(io.swagger.v3.oas.models.PathItem) ExternalDocumentation(io.swagger.v3.oas.models.ExternalDocumentation) MediaType(io.swagger.v3.oas.models.media.MediaType) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Paths(io.swagger.v3.oas.models.Paths) ApiResponses(io.swagger.v3.oas.models.responses.ApiResponses) IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) Info(io.swagger.v3.oas.models.info.Info) BigDecimal(java.math.BigDecimal) Contact(io.swagger.v3.oas.models.info.Contact) Content(io.swagger.v3.oas.models.media.Content) Tag(io.swagger.v3.oas.models.tags.Tag) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Link(io.swagger.v3.oas.models.links.Link) Test(org.testng.annotations.Test)

Example 42 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse 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 43 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse in project oxTrust by GluuFederation.

the class PassportProviderWebResource method updatePassportProvider.

@PUT
@Operation(summary = "Update passport provider", description = "Update passport provider")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Provider.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updatePassportProvider(Provider provider) {
    String id = provider.getId();
    id = id.equalsIgnoreCase("") ? null : id;
    log(logger, "Update passport provider " + id);
    try {
        Objects.requireNonNull(id, "id should not be null");
        this.ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
        this.passportConfiguration = this.ldapOxPassportConfiguration.getPassportConfiguration();
        List<Provider> providers = new ArrayList<>();
        providers.addAll(this.passportConfiguration.getProviders());
        Provider existingProvider = getExistingProvider(providers, id);
        if (existingProvider != null) {
            providers.remove(existingProvider);
            providers.add(provider);
            this.passportConfiguration.setProviders(providers);
            this.ldapOxPassportConfiguration.setPassportConfiguration(this.passportConfiguration);
            this.passportService.updateLdapOxPassportConfiguration(this.ldapOxPassportConfiguration);
            return Response.ok(provider).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : ArrayList(java.util.ArrayList) Provider(org.gluu.model.passport.Provider) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 44 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse in project oxTrust by GluuFederation.

the class GluuRadiusConfigWebResource method updateServerConfiguration.

@PUT
@Operation(summary = "Get Radius Server Configuration", description = "Update Radius Server Configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ServerConfiguration.class)), description = "Success"), @ApiResponse(responseCode = "403", description = "Gluu Radius is not installed"), @ApiResponse(responseCode = "404", description = "Gluu Radius configuration not found"), @ApiResponse(responseCode = "500", description = "Internal server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateServerConfiguration(ServerConfiguration newConfig) {
    log(logger, "Update radius server configuration");
    try {
        if (ProductInstallationChecker.isGluuRadiusInstalled() == false)
            return Response.status(Response.Status.FORBIDDEN).build();
        Objects.requireNonNull(newConfig);
        ServerConfiguration oldConfig = gluuRadiusConfigService.getServerConfiguration();
        if (oldConfig == null)
            return Response.status(Response.Status.NOT_FOUND).build();
        if (newConfig.getListenInterface() == null)
            newConfig.setListenInterface(oldConfig.getListenInterface());
        if (newConfig.getAuthPort() == null)
            newConfig.setAuthPort(oldConfig.getAuthPort());
        if (newConfig.getAcctPort() == null)
            newConfig.setAcctPort(oldConfig.getAcctPort());
        if (newConfig.getOpenidBaseUrl() == null)
            newConfig.setOpenidBaseUrl(oldConfig.getOpenidBaseUrl());
        if (newConfig.getOpenidUsername() == null) {
            newConfig.setOpenidUsername(oldConfig.getOpenidUsername());
            newConfig.setOpenidPassword(oldConfig.getOpenidPassword());
        } else {
            OxAuthClient client = clientService.getClientByInum(newConfig.getOpenidUsername());
            if (client == null) {
                newConfig.setOpenidUsername(oldConfig.getOpenidUsername());
                newConfig.setOpenidPassword(oldConfig.getOpenidPassword());
            } else {
                newConfig.setOpenidPassword(client.getEncodedClientSecret());
            }
        }
        String acrValue = newConfig.getAcrValue();
        if (acrValue == null || (acrValue != null && !isValidAcrValue(acrValue)))
            newConfig.setAcrValue(oldConfig.getAcrValue());
        List<String> scopes = newConfig.getScopes();
        if (scopes == null || (scopes != null && scopes.isEmpty()))
            newConfig.setScopes(oldConfig.getScopes());
        else {
            List<String> newscopes = scopes;
            for (String scope : scopes) {
                // if just one scope is invalid , use the old ones (safe)
                if (!isValidScope(scope)) {
                    newscopes = oldConfig.getScopes();
                    break;
                }
            }
            newConfig.setScopes(newscopes);
        }
        if (newConfig.getAuthenticationTimeout() == null || newConfig.getAuthenticationTimeout() <= 0)
            newConfig.setAuthenticationTimeout(oldConfig.getAuthenticationTimeout());
        gluuRadiusConfigService.updateServerConfiguration(newConfig);
        return Response.ok(gluuRadiusConfigService.getServerConfiguration()).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) ServerConfiguration(org.gluu.radius.model.ServerConfiguration) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 45 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse in project oxTrust by GluuFederation.

the class CasProtocolWebResource method update.

@PUT
@Operation(summary = "Update the configuration", description = "Update the configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = CasProtocolDTO.class)), description = "Success") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response update(@Valid CasProtocolDTO casProtocol) {
    log(logger, "Update the configuration");
    try {
        CASProtocolConfiguration casProtocolConfiguration = casProtocolDtoAssembly.fromDto(casProtocol);
        casProtocolConfiguration.save(casService);
        shibbolethService.update(casProtocolConfiguration);
        return getCasConfig();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : CASProtocolConfiguration(org.gluu.oxtrust.util.CASProtocolConfiguration) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)113 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)99 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)84 Test (org.testng.annotations.Test)53 Operation (io.swagger.v3.oas.models.Operation)50 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)48 OpenAPI (io.swagger.v3.oas.models.OpenAPI)47 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)43 PathItem (io.swagger.v3.oas.models.PathItem)39 Schema (io.swagger.v3.oas.models.media.Schema)38 MediaType (io.swagger.v3.oas.models.media.MediaType)31 Path (javax.ws.rs.Path)30 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)29 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)27 StringSchema (io.swagger.v3.oas.models.media.StringSchema)27 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)25 Content (io.swagger.v3.oas.models.media.Content)25 ArrayList (java.util.ArrayList)24 Components (io.swagger.v3.oas.models.Components)19 Parameter (io.swagger.v3.oas.models.parameters.Parameter)18