Stop field snippets requiring a type for missing, optional, ignored field
Missing optional fields require a type to be explicitly provided as it cannot be inferred from the payload. Ignored fields are not included in the documentation, yet, previously, a field that was missing, optional, and ignored would still require a type to be provided otherwise the test would fail. This was pointless as the field wasn't going to appear in the documentation. This commit updates the fields snippets so that a type is no longer required for a field that is missing, optional and ignored. Closes gh-289
This commit is contained in:
@@ -100,15 +100,17 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
|
||||
validateFieldDocumentation(contentHandler);
|
||||
|
||||
for (FieldDescriptor descriptor : this.fieldDescriptors) {
|
||||
try {
|
||||
descriptor.type(contentHandler.determineFieldType(descriptor));
|
||||
}
|
||||
catch (FieldDoesNotExistException ex) {
|
||||
String message = "Cannot determine the type of the field '"
|
||||
+ descriptor.getPath() + "' as it is not present in the "
|
||||
+ "payload. Please provide a type using "
|
||||
+ "FieldDescriptor.type(Object type).";
|
||||
throw new FieldTypeRequiredException(message);
|
||||
if (!descriptor.isIgnored()) {
|
||||
try {
|
||||
descriptor.type(contentHandler.determineFieldType(descriptor));
|
||||
}
|
||||
catch (FieldDoesNotExistException ex) {
|
||||
String message = "Cannot determine the type of the field '"
|
||||
+ descriptor.getPath() + "' as it is not present in the "
|
||||
+ "payload. Please provide a type using "
|
||||
+ "FieldDescriptor.type(Object type).";
|
||||
throw new FieldTypeRequiredException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user