Search in sources :

Example 1 with HeaderParameter

use of io.swagger.v3.oas.models.parameters.HeaderParameter in project syncope by apache.

the class SyncopeOpenApiCustomizer method addParameters.

@Override
protected void addParameters(final List<Parameter> parameters) {
    if (domains == null) {
        domains = new ArrayList<>(ApplicationContextProvider.getApplicationContext().getBean(DomainsHolder.class).getDomains().keySet());
    }
    Optional<Parameter> domainHeaderParameter = parameters.stream().filter(parameter -> parameter instanceof HeaderParameter && RESTHeaders.DOMAIN.equals(parameter.getName())).findFirst();
    if (!domainHeaderParameter.isPresent()) {
        HeaderParameter parameter = new HeaderParameter();
        parameter.setName(RESTHeaders.DOMAIN);
        parameter.setRequired(true);
        Schema<String> schema = new Schema<>();
        schema.setType("string");
        schema.setEnum(domains);
        schema.setDefault(SyncopeConstants.MASTER_DOMAIN);
        parameter.setSchema(schema);
        parameters.add(parameter);
    }
}
Also used : ApiResponse(io.swagger.v3.oas.models.responses.ApiResponse) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) Content(io.swagger.v3.oas.models.media.Content) URL(java.net.URL) MediaType(io.swagger.v3.oas.models.media.MediaType) Parameter(io.swagger.v3.oas.models.parameters.Parameter) OpenAPIConfiguration(io.swagger.v3.oas.integration.api.OpenAPIConfiguration) Header(io.swagger.v3.oas.models.headers.Header) ErrorTO(org.apache.syncope.common.lib.to.ErrorTO) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) DomainsHolder(org.apache.syncope.core.persistence.api.DomainsHolder) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) Map(java.util.Map) OpenApiCustomizer(org.apache.cxf.jaxrs.openapi.OpenApiCustomizer) Optional(java.util.Optional) Schema(io.swagger.v3.oas.models.media.Schema) RESTHeaders(org.apache.syncope.common.rest.api.RESTHeaders) ApplicationContextProvider(org.apache.syncope.core.spring.ApplicationContextProvider) Schema(io.swagger.v3.oas.models.media.Schema) Parameter(io.swagger.v3.oas.models.parameters.Parameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter)

Aggregations

OpenAPIConfiguration (io.swagger.v3.oas.integration.api.OpenAPIConfiguration)1 Header (io.swagger.v3.oas.models.headers.Header)1 Content (io.swagger.v3.oas.models.media.Content)1 MediaType (io.swagger.v3.oas.models.media.MediaType)1 Schema (io.swagger.v3.oas.models.media.Schema)1 HeaderParameter (io.swagger.v3.oas.models.parameters.HeaderParameter)1 Parameter (io.swagger.v3.oas.models.parameters.Parameter)1 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 OpenApiCustomizer (org.apache.cxf.jaxrs.openapi.OpenApiCustomizer)1 SyncopeConstants (org.apache.syncope.common.lib.SyncopeConstants)1 ErrorTO (org.apache.syncope.common.lib.to.ErrorTO)1 RESTHeaders (org.apache.syncope.common.rest.api.RESTHeaders)1 DomainsHolder (org.apache.syncope.core.persistence.api.DomainsHolder)1 ApplicationContextProvider (org.apache.syncope.core.spring.ApplicationContextProvider)1