use of io.swagger.v3.oas.models.security.SecurityScheme.In in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1644_NullValue.
@Test
public void testIssue1644_NullValue() throws Exception {
ParseOptions options = new ParseOptions();
String issue1644 = "openapi: 3.0.0\n" + "info:\n" + " title: Operations\n" + " version: 0.0.0\n" + "paths:\n" + " \"/operations\":\n" + " post:\n" + " parameters:\n" + " - name: param0\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: None\n";
SwaggerParseResult result = new OpenAPIV3Parser().readContents(issue1644, null, options);
Assert.assertNotNull(result);
Assert.assertNotNull(result.getOpenAPI());
assertEquals(result.getMessages().size(), 1);
assertTrue(result.getMessages().contains("attribute paths.'/operations'(post).parameters.[param0].in is missing"));
assertFalse(result.getMessages().contains("attribute paths.'/operations'(post).parameters.[param0].in is not of type `string`"));
}
use of io.swagger.v3.oas.models.security.SecurityScheme.In in project ballerina by ballerina-lang.
the class SwaggerConverterUtils method getTopLevelNodeFromBallerinaFile.
/**
* Generate ballerina fine from the String definition.
*
* @param bFile ballerina string definition
* @return ballerina file created from ballerina string definition
* @throws IOException IO exception
*/
public static BLangCompilationUnit getTopLevelNodeFromBallerinaFile(BFile bFile) throws IOException {
String filePath = bFile.getFilePath();
String fileName = bFile.getFileName();
String content = bFile.getContent();
Path fileRoot = Paths.get(filePath);
org.wso2.ballerinalang.compiler.tree.BLangPackage model;
// Sometimes we are getting Ballerina content without a file in the file-system.
if (!Files.exists(Paths.get(filePath, fileName))) {
BallerinaFile ballerinaFile = ParserUtils.getBallerinaFileForContent(fileRoot, fileName, content, CompilerPhase.CODE_ANALYZE);
model = ballerinaFile.getBLangPackage();
} else {
BallerinaFile ballerinaFile = ParserUtils.getBallerinaFile(filePath, fileName);
model = ballerinaFile.getBLangPackage();
}
final Map<String, ModelPackage> modelPackage = new HashMap<>();
ParserUtils.loadPackageMap(Constants.CURRENT_PACKAGE_NAME, model, modelPackage);
Optional<BLangCompilationUnit> compilationUnit = model.getCompilationUnits().stream().filter(compUnit -> fileName.equals(compUnit.getName())).findFirst();
return compilationUnit.orElse(null);
}
use of io.swagger.v3.oas.models.security.SecurityScheme.In in project cas by apereo.
the class LoggingConfigurationEndpoint method updateLoggerLevel.
/**
* Looks up the logger in the logger factory,
* and attempts to find the real logger instance
* based on the underlying logging framework
* and retrieve the logger object. Then, updates the level.
* This functionality at this point is heavily dependant
* on the log4j API.
*
* @param loggerName the logger name
* @param loggerLevel the logger level
* @param additive the additive nature of the logger
*/
@WriteOperation
@Operation(summary = "Update logger level for a logger name", parameters = { @Parameter(name = "loggerName", required = true), @Parameter(name = "loggerLevel", required = true), @Parameter(name = "additive") })
public void updateLoggerLevel(@Selector final String loggerName, final String loggerLevel, final boolean additive) {
val loggerConfigs = getLoggerConfigurations();
loggerConfigs.stream().filter(cfg -> cfg.getName().equals(loggerName)).forEachOrdered(cfg -> {
cfg.setLevel(Level.getLevel(loggerLevel));
cfg.setAdditive(additive);
});
this.loggerContext.updateLoggers();
}
use of io.swagger.v3.oas.models.security.SecurityScheme.In in project cas by apereo.
the class DuoSecurityAdminApiEndpoint method getUser.
/**
* Fetch duo user account from admin api.
*
* @param username the username
* @param providerId the provider id
* @return the map
*/
@GetMapping(path = "/{username}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Fetch Duo Security user account from Duo Admin API", parameters = { @Parameter(name = "username", required = true, in = ParameterIn.PATH), @Parameter(name = "providerId") })
public Map<String, DuoSecurityUserAccount> getUser(@PathVariable("username") final String username, @RequestParam(required = false) final String providerId) {
val results = new LinkedHashMap<String, DuoSecurityUserAccount>();
val providers = applicationContext.getBeansOfType(DuoSecurityMultifactorAuthenticationProvider.class).values();
providers.stream().filter(Objects::nonNull).map(DuoSecurityMultifactorAuthenticationProvider.class::cast).filter(provider -> StringUtils.isBlank(providerId) || provider.matches(providerId)).filter(provider -> provider.getDuoAuthenticationService().getAdminApiService().isPresent()).forEach(Unchecked.consumer(p -> {
val duoService = p.getDuoAuthenticationService().getAdminApiService().get();
duoService.getDuoSecurityUserAccount(username).ifPresent(user -> results.put(p.getId(), user));
}));
return results;
}
use of io.swagger.v3.oas.models.security.SecurityScheme.In in project swagger-core by swagger-api.
the class SecuritySchemeDeserializer method deserialize.
@Override
public SecurityScheme deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = null;
if (openapi31) {
mapper = Json31.mapper();
} else {
mapper = Json.mapper();
}
SecurityScheme result = null;
JsonNode node = jp.getCodec().readTree(jp);
JsonNode inNode = node.get("type");
if (inNode != null) {
String type = inNode.asText();
if (Arrays.stream(SecurityScheme.Type.values()).noneMatch(t -> t.toString().equals(type))) {
// wrong type, throw exception
throw new JsonParseException(jp, String.format("SecurityScheme type %s not allowed", type));
}
result = new SecurityScheme().description(getFieldText("description", node));
if ("http".equals(type)) {
result.type(SecurityScheme.Type.HTTP).scheme(getFieldText("scheme", node)).bearerFormat(getFieldText("bearerFormat", node));
} else if ("apiKey".equals(type)) {
result.type(SecurityScheme.Type.APIKEY).name(getFieldText("name", node)).in(getIn(getFieldText("in", node)));
} else if ("openIdConnect".equals(type)) {
result.type(SecurityScheme.Type.OPENIDCONNECT).openIdConnectUrl(getFieldText("openIdConnectUrl", node));
} else if ("oauth2".equals(type)) {
result.type(SecurityScheme.Type.OAUTH2).flows(mapper.convertValue(node.get("flows"), OAuthFlows.class));
} else if ("mutualTLS".equals(type)) {
result.type(SecurityScheme.Type.MUTUALTLS);
}
}
return result;
}
Aggregations