Java Code Examples for io.swagger.v3.parser.core.models.ParseOptions#isResolve()

The following examples show how to use io.swagger.v3.parser.core.models.ParseOptions#isResolve() . 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: OpenAPIV3Parser.java    From swagger-parser with Apache License 2.0 6 votes vote down vote up
private SwaggerParseResult resolve(SwaggerParseResult result, List<AuthorizationValue> auth, ParseOptions options,
        String location) {
    try {
        if (options != null) {
            if (options.isResolve() || options.isResolveFully()) {
                result.setOpenAPI(new OpenAPIResolver(result.getOpenAPI(), emptyListIfNull(auth),
                        location).resolve());
                if (options.isResolveFully()) {
                    new ResolverFully(options.isResolveCombinators()).resolveFully(result.getOpenAPI());
                }
            }
            if (options.isFlatten()) {
                final InlineModelResolver inlineModelResolver =
                        new InlineModelResolver(options.isFlattenComposedSchemas(),
                                options.isCamelCaseFlattenNaming(), options.isSkipMatches());
                inlineModelResolver.flatten(result.getOpenAPI());
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Exception while resolving:", e);
        result.setMessages(Collections.singletonList(e.getMessage()));
    }
    return result;
}
 
Example 2
Source File: SwaggerConverter.java    From swagger-parser with Apache License 2.0 5 votes vote down vote up
@Override
public SwaggerParseResult readLocation(String url, List<AuthorizationValue> auths, ParseOptions options) {
    boolean resolve = false;
    if (options != null) {
        resolve = options.isResolve();
    }

    SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(url, convert(auths), resolve);

    return readResult(result, auths, options);
}
 
Example 3
Source File: SwaggerConverter.java    From swagger-parser with Apache License 2.0 5 votes vote down vote up
@Override
public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options) {
    SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(swaggerAsString, options == null ?
            true : options.isResolve());

    if (options != null) {
        if (options.isResolve()) {
            Swagger resolved = new SwaggerResolver(result.getSwagger(), convert(auth)).resolve();
            result.setSwagger(resolved);
        }
    }
    return readResult(result, auth, options);

}