Skip to content

Commit

Permalink
[SHIBUI-701]
Browse files Browse the repository at this point in the history
Added support to get a SchemaType by json type.
  • Loading branch information
Bill Smith committed Nov 9, 2018
1 parent 3fa8e14 commit e7dd96f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MetadataResolverUiDefinitionController {

@GetMapping(value = "/{resolverType}")
ResponseEntity<?> getUiDefinitionJsonSchema(@PathVariable String resolverType) {
switch (SchemaType.valueOf(resolverType)) {
switch (SchemaType.getSchemaType(resolverType)) {
case SchemaType.FILESYSTEM_METADATA_RESOLVER:
jsonSchemaLocation = filesystemMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry)
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,14 @@ String getJsonType() {
public static List<String> getResolverTypes() {
return Stream.of(SchemaType.values()).map(SchemaType::getJsonType).filter(it -> it.endsWith("Resolver")).collect(Collectors.toList());
}

public static SchemaType getSchemaType(String jsonType) {
List<SchemaType> schemaTypes = Stream.of(SchemaType.values()).filter(it -> it.getJsonType().equals(jsonType)).collect(Collectors.toList());
if (schemaTypes.size() != 1) {
throw new RuntimeException("Found two schema types for jsonType (" + jsonType + ")! How did this even happen?");
} else {
return schemaTypes.get(0);
}
}
}
}

0 comments on commit e7dd96f

Please sign in to comment.