use of io.swagger.v3.oas.models.Operation in project cas by apereo.
the class WebAuthnRegisteredDevicesEndpoint method delete.
/**
* Delete.
*
* @param username the username
* @param credentialId the credential id
* @throws Exception the exception
*/
@Operation(summary = "Remove device registration for username and credential id", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "credentialId", required = true) })
@DeleteMapping(path = "{username}/{credentialId}", produces = MediaType.APPLICATION_JSON_VALUE)
public void delete(@PathVariable final String username, @PathVariable final String credentialId) throws Exception {
val ba = ByteArray.fromBase64Url(credentialId);
registrationStorage.getObject().getRegistrationByUsernameAndCredentialId(username, ba).ifPresent(registration -> registrationStorage.getObject().removeRegistrationByUsername(username, registration));
}
use of io.swagger.v3.oas.models.Operation in project cas by apereo.
the class WebAuthnRegisteredDevicesEndpoint method write.
/**
* Write.
*
* @param username the username
* @param record the record
* @return the boolean
* @throws Exception the exception
*/
@PostMapping(path = "{username}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Add device registration for username", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "record", required = true) })
public boolean write(@PathVariable final String username, @RequestParam final String record) throws Exception {
val json = EncodingUtils.decodeBase64ToString(record);
val registration = WebAuthnUtils.getObjectMapper().readValue(json, CredentialRegistration.class);
return registrationStorage.getObject().addRegistrationByUsername(username, registration);
}
use of io.swagger.v3.oas.models.Operation in project cas by apereo.
the class WebAuthnRegisteredDevicesEndpoint method importAccount.
/**
* Import account.
*
* @param request the request
* @return the http status
* @throws Exception the exception
*/
@Operation(summary = "Import a device registration as a JSON document")
@PostMapping(path = "/import", consumes = MediaType.APPLICATION_JSON_VALUE)
public HttpStatus importAccount(final HttpServletRequest request) throws Exception {
val requestBody = IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8);
LOGGER.trace("Submitted account: [{}]", requestBody);
val account = WebAuthnUtils.getObjectMapper().readValue(requestBody, new TypeReference<CredentialRegistration>() {
});
LOGGER.trace("Storing account: [{}]", account);
registrationStorage.getObject().addRegistrationByUsername(account.getUsername(), account);
return HttpStatus.CREATED;
}
use of io.swagger.v3.oas.models.Operation in project swagger-core by swagger-api.
the class MapPropertyDeserializerTest method testBooleanAdditionalPropertiesDeserialization.
@Test(description = "it should deserialize a boolean additionalProperties")
public void testBooleanAdditionalPropertiesDeserialization() throws Exception {
Operation operation = Json.mapper().readValue(jsonAdditionalPropertiesBoolean, Operation.class);
ApiResponse response = operation.getResponses().get("200");
assertNotNull(response);
Schema responseSchema = response.getContent().get("*/*").getSchema();
assertNotNull(responseSchema);
assertTrue(responseSchema instanceof ObjectSchema);
assertTrue(responseSchema.getAdditionalProperties() instanceof Boolean);
Assert.assertFalse((Boolean) responseSchema.getAdditionalProperties());
operation = Json.mapper().readValue(jsonAdditionalPropertiesBooleanTrue, Operation.class);
response = operation.getResponses().get("200");
assertNotNull(response);
responseSchema = response.getContent().get("*/*").getSchema();
assertNotNull(responseSchema);
assertTrue(responseSchema instanceof MapSchema);
assertTrue(responseSchema.getAdditionalProperties() instanceof Boolean);
Assert.assertTrue((Boolean) responseSchema.getAdditionalProperties());
}
use of io.swagger.v3.oas.models.Operation in project swagger-core by swagger-api.
the class MapPropertyDeserializerTest method testMapDeserializationVendorExtensions.
@Test(description = "vendor extensions should be included with object type")
public void testMapDeserializationVendorExtensions() throws Exception {
Operation operation = Json.mapper().readValue(json, Operation.class);
ApiResponse response = operation.getResponses().get("200");
assertNotNull(response);
Schema responseSchema = response.getContent().get("*/*").getSchema();
assertNotNull(responseSchema);
MapSchema mp = (MapSchema) responseSchema;
assertTrue(mp.getExtensions().size() > 0);
assertNotNull(mp.getExtensions().get("x-foo"));
assertEquals(mp.getExtensions().get("x-foo"), "vendor x");
}
Aggregations