io.swagger.models.auth.AuthorizationValue Java Examples

The following examples show how to use io.swagger.models.auth.AuthorizationValue. 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: AuthParser.java    From TypeScript-Microservices with MIT License 6 votes vote down vote up
public static String reconstruct(List<AuthorizationValue> authorizationValueList) {
    if (authorizationValueList != null) {
        StringBuilder b = new StringBuilder();
        for (AuthorizationValue v : authorizationValueList) {
            try {
                if (b.toString().length() > 0) {
                    b.append(",");
                }
                b.append(URLEncoder.encode(v.getKeyName(), "UTF-8"))
                        .append(":")
                        .append(URLEncoder.encode(v.getValue(), "UTF-8"));
            } catch (Exception e) {
                // continue
                LOGGER.error(e.getMessage(), e);
            }
        }
        return b.toString();
    } else {
        return null;
    }
}
 
Example #2
Source File: SwaggerDiff.java    From swagger-diff with Apache License 2.0 6 votes vote down vote up
/**
 * @param oldSpec
 * @param newSpec
 * @param auths
 * @param version
 */
private SwaggerDiff(String oldSpec, String newSpec, List<AuthorizationValue> auths,
        String version) {
    if (SWAGGER_VERSION_V2.equals(version)) {
        SwaggerParser swaggerParser = new SwaggerParser();
        oldSpecSwagger = swaggerParser.read(oldSpec, auths, true);
        newSpecSwagger = swaggerParser.read(newSpec, auths, true);
    } else {
        SwaggerCompatConverter swaggerCompatConverter = new SwaggerCompatConverter();
        try {
            oldSpecSwagger = swaggerCompatConverter.read(oldSpec, auths);
            newSpecSwagger = swaggerCompatConverter.read(newSpec, auths);
        } catch (IOException e) {
            logger.error("cannot read api-doc from spec[version_v1.x]", e);
            return;
        }
    }
    if (null == oldSpecSwagger || null == newSpecSwagger) { throw new RuntimeException(
            "cannot read api-doc from spec."); }
}
 
Example #3
Source File: AuthParser.java    From TypeScript-Microservices with MIT License 5 votes vote down vote up
public static List<AuthorizationValue> parse(String urlEncodedAuthStr) {
    List<AuthorizationValue> auths = new ArrayList<AuthorizationValue>();
    if (isNotEmpty(urlEncodedAuthStr)) {
        String[] parts = urlEncodedAuthStr.split(",");
        for (String part : parts) {
            String[] kvPair = part.split(":");
            if (kvPair.length == 2) {
                // FIXME replace the deprecated method by decode(string, encoding). Which encoding is used ? Default UTF-8 ?
                auths.add(new AuthorizationValue(URLDecoder.decode(kvPair[0]), URLDecoder.decode(kvPair[1]), "header"));
            }
        }
    }
    return auths;
}
 
Example #4
Source File: GeneratorInput.java    From TypeScript-Microservices with MIT License 4 votes vote down vote up
public AuthorizationValue getAuthorizationValue() {
    return authorizationValue;
}
 
Example #5
Source File: GeneratorInput.java    From TypeScript-Microservices with MIT License 4 votes vote down vote up
public void setAuthorizationValue(AuthorizationValue authorizationValue) {
    this.authorizationValue = authorizationValue;
}
 
Example #6
Source File: CodegenConfigurator.java    From TypeScript-Microservices with MIT License 4 votes vote down vote up
public ClientOptInput toClientOptInput() {

        Validate.notEmpty(lang, "language must be specified");
        Validate.notEmpty(inputSpec, "input spec must be specified");

        setVerboseFlags();
        setSystemProperties();

        CodegenConfig config = CodegenConfigLoader.forName(lang);

        config.setInputSpec(inputSpec);
        config.setOutputDir(outputDir);
        config.setSkipOverwrite(skipOverwrite);
        config.setIgnoreFilePathOverride(ignoreFileOverride);
        config.setRemoveOperationIdPrefix(removeOperationIdPrefix);

        config.instantiationTypes().putAll(instantiationTypes);
        config.typeMapping().putAll(typeMappings);
        config.importMapping().putAll(importMappings);
        config.languageSpecificPrimitives().addAll(languageSpecificPrimitives);
        config.reservedWordsMappings().putAll(reservedWordMappings);

        checkAndSetAdditionalProperty(apiPackage, CodegenConstants.API_PACKAGE);
        checkAndSetAdditionalProperty(modelPackage, CodegenConstants.MODEL_PACKAGE);
        checkAndSetAdditionalProperty(invokerPackage, CodegenConstants.INVOKER_PACKAGE);
        checkAndSetAdditionalProperty(groupId, CodegenConstants.GROUP_ID);
        checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID);
        checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION);
        checkAndSetAdditionalProperty(templateDir, toAbsolutePathStr(templateDir), CodegenConstants.TEMPLATE_DIR);
        checkAndSetAdditionalProperty(modelNamePrefix, CodegenConstants.MODEL_NAME_PREFIX);
        checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX);
        checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID);
        checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID);
        checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE);
        checkAndSetAdditionalProperty(httpUserAgent, CodegenConstants.HTTP_USER_AGENT);

        handleDynamicProperties(config);

        if (isNotEmpty(library)) {
            config.setLibrary(library);
        }

        config.additionalProperties().putAll(additionalProperties);

        ClientOptInput input = new ClientOptInput()
                .config(config);

        final List<AuthorizationValue> authorizationValues = AuthParser.parse(auth);

        Swagger swagger = new SwaggerParser().read(inputSpec, authorizationValues, true);

        input.opts(new ClientOpts())
                .swagger(swagger);

        return input;
    }
 
Example #7
Source File: ClientOptInput.java    From TypeScript-Microservices with MIT License 4 votes vote down vote up
@Deprecated
public List<AuthorizationValue> getAuthorizationValues() {
    return auths;
}
 
Example #8
Source File: GeneratorInput.java    From sc-generator with Apache License 2.0 4 votes vote down vote up
public AuthorizationValue getAuthorizationValue() {
    return authorizationValue;
}
 
Example #9
Source File: GeneratorInput.java    From sc-generator with Apache License 2.0 4 votes vote down vote up
public void setAuthorizationValue(AuthorizationValue authorizationValue) {
    this.authorizationValue = authorizationValue;
}
 
Example #10
Source File: SwaggerDiff.java    From swagger-diff with Apache License 2.0 4 votes vote down vote up
public static SwaggerDiff compare(String oldSpec, String newSpec,
        List<AuthorizationValue> auths, String version) {
    return new SwaggerDiff(oldSpec, newSpec, auths, version).compare();
}
 
Example #11
Source File: SwaggerAssert.java    From assertj-swagger with Apache License 2.0 2 votes vote down vote up
/**
 * Verifies that the actual value is equal to the given one.
 *
 * @param expectedLocation the location of the given value to compare the actual value to.
 * @param auths List of io.swagger.models.auth.AuthorizationValue for access to protected locations.
 * @return {@code this} assertion object.
 * @throws AssertionError if the actual value is not equal to the given one or if the actual value is {@code null}..
 */
public SwaggerAssert isEqualTo(String expectedLocation, List<AuthorizationValue> auths) {
    return isEqualTo(new SwaggerParser().read(expectedLocation, auths, true));
}
 
Example #12
Source File: SwaggerAssert.java    From assertj-swagger with Apache License 2.0 2 votes vote down vote up
/**
 * Verifies that the actual value is equal to the given one.
 *
 * @param expectedLocation the location of the given value to compare the actual value to.
 * @param auths List of io.swagger.models.auth.AuthorizationValue for access to protected locations.
 * @return {@code this} assertion object.
 * @throws AssertionError if the actual value is not equal to the given one or if the actual value is {@code null}..
 */
public SwaggerAssert satisfiesContract(String expectedLocation, List<AuthorizationValue> auths) {
    return satisfiesContract(new SwaggerParser().read(expectedLocation, auths, true));
}