use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class SwaggerConverter method readResult.
private SwaggerParseResult readResult(SwaggerDeserializationResult result, List<AuthorizationValue> auth, ParseOptions options) {
SwaggerParseResult out = convert(result);
if (out != null && options != null) {
if (options.isResolveFully()) {
new ResolverFully(options.isResolveCombinators()).resolveFully(out.getOpenAPI());
}
if (options.isFlatten()) {
try {
SwaggerParseResult resultV3 = new OpenAPIV3Parser().readContents(Yaml.pretty(out.getOpenAPI()), auth, options);
out.setOpenAPI(resultV3.getOpenAPI());
if (out.getMessages() != null) {
out.getMessages().addAll(resultV3.getMessages());
out.messages(out.getMessages().stream().distinct().collect(Collectors.toList()));
} else {
out.messages(resultV3.getMessages());
}
} catch (Exception ignore) {
}
}
}
return out;
}
use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class OpenAPIV3Parser method transform.
/**
* Transform the swagger-model version of AuthorizationValue into a parser-specific one, to avoid
* dependencies across extensions
*
* @param input
* @return
*/
@Deprecated
protected List<AuthorizationValue> transform(List<AuthorizationValue> input) {
if (input == null) {
return null;
}
List<AuthorizationValue> output = new ArrayList<>();
for (AuthorizationValue value : input) {
AuthorizationValue v = new AuthorizationValue();
v.setKeyName(value.getKeyName());
v.setValue(value.getValue());
v.setType(value.getType());
v.setUrlMatcher(value.getUrlMatcher());
output.add(v);
}
return output;
}
use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class OpenAPIV3Parser method read.
public OpenAPI read(String location, List<AuthorizationValue> auths, ParseOptions resolve) {
if (location == null) {
return null;
}
final List<SwaggerParserExtension> parserExtensions = getExtensions();
SwaggerParseResult parsed;
for (SwaggerParserExtension extension : parserExtensions) {
parsed = extension.readLocation(location, auths, resolve);
for (String message : parsed.getMessages()) {
LOGGER.info("{}: {}", extension, message);
}
final OpenAPI result = parsed.getOpenAPI();
if (result != null) {
return result;
}
}
return null;
}
use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class SwaggerConverter method convert.
public List<io.swagger.models.auth.AuthorizationValue> convert(List<AuthorizationValue> auths) {
List<io.swagger.models.auth.AuthorizationValue> convertedAuth = new ArrayList<>();
if (auths != null) {
for (AuthorizationValue auth : auths) {
io.swagger.models.auth.AuthorizationValue v = new io.swagger.models.auth.AuthorizationValue();
v.setType(auth.getType());
v.setValue(auth.getValue());
v.setKeyName(auth.getKeyName());
convertedAuth.add(v);
}
}
return convertedAuth;
}
use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class V2ConverterTest method testIssue785.
@Test(description = "OpenAPIParser.readLocation fails when fetching valid Swagger 2.0 resource with AuthorizationValues provided")
public void testIssue785() {
AuthorizationValue apiKey = new AuthorizationValue("api_key", "special-key", "header");
List<AuthorizationValue> authorizationValues = Arrays.asList(apiKey);
SwaggerConverter converter = new SwaggerConverter();
List<io.swagger.models.auth.AuthorizationValue> convertedAuthList = converter.convert(authorizationValues);
assertEquals(convertedAuthList.size(), authorizationValues.size());
}
Aggregations