-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EES-5494 Re-work schema property validation rendering
This change adds missing validations and now renders validations for child items (for arrays).
- Loading branch information
Showing
4 changed files
with
76 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,41 @@ | ||
<%= description %> | ||
|
||
<% is_referenced_schema = schema.node_context.document_location != schema.node_context.source_location %> | ||
<% if schema.default %> | ||
Defaults to: `<%= schema.default %>` | ||
<% end %> | ||
|
||
<% if has_schema_validations(schema) %> | ||
Validation constraints: | ||
|
||
<%= partial("partials/schema_validations", :locals => { schema: schema }) %> | ||
<% end %> | ||
|
||
<% is_referenced_schema = | ||
schema.node_context.document_location != schema.node_context.source_location %> | ||
|
||
<% if !is_referenced_schema && schema.enum %> | ||
Available options: | ||
Allowed options: | ||
|
||
<% schema.enum.each do |item| %> | ||
- `<%= item %>` | ||
<% end %> | ||
<% end %> | ||
|
||
<%# TODO: Add other validation rules %> | ||
<% unless schema.minimum.nil? && schema.maximum.nil? && schema.format.nil? %> | ||
<% if schema.minimum %> | ||
- <%= schema.exclusive_minimum? ? 'Minimum (exclusive)' : 'Minimum' %>: `<%= schema.minimum %>` | ||
<% end %> | ||
<% if schema.type == "array" && schema.items != nil %> | ||
<% if has_schema_validations(schema.items) %> | ||
Validation constraints for child items: | ||
|
||
<% if schema.maximum %> | ||
- <%= schema.exclusive_maximum? ? 'Maximum (exclusive)' : 'Maximum' %>: `<%= schema.maximum %>` | ||
<%= partial("partials/schema_validations", :locals => { schema: schema.items }) %> | ||
<% end %> | ||
|
||
<% if schema.format %> | ||
- Format: `<%= schema.format %>` | ||
<% is_referenced_child_schema = | ||
schema.items.node_context.document_location != schema.items.node_context.source_location %> | ||
|
||
<% if !is_referenced_child_schema && schema.items.enum %> | ||
Allowed options for child items: | ||
|
||
<% schema.items.enum.each do |item| %> | ||
- `<%= item %>` | ||
<% end %> | ||
<% end %> | ||
|
||
<% if schema.default %> | ||
Defaults to: `<%= schema.default %>` | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<% if schema.format %> | ||
- Format: `<%= schema.format %>` | ||
<% end %> | ||
|
||
<% unless schema.max_length.nil? %> | ||
- Maximum length: `<%= schema.max_length %>` | ||
<% end %> | ||
<% if schema.min_length != 0 %> | ||
- Minimum length: `<%= schema.min_length %>` | ||
<% end %> | ||
|
||
<% unless schema.max_items.nil? %> | ||
- Maximum items: `<%= schema.max_items %>` | ||
<% end %> | ||
<% if schema.min_items != 0 %> | ||
- Minimum items: `<%= schema.min_items %>` | ||
<% end %> | ||
|
||
<% if schema.unique_items? %> | ||
- Items must be unique | ||
<% end %> | ||
|
||
<% unless schema.minimum.nil? && schema.maximum.nil? && schema.format.nil? %> | ||
<% if schema.minimum %> | ||
- <%= schema.exclusive_minimum? ? 'Minimum (exclusive)' : 'Minimum' %>: `<%= schema.minimum %>` | ||
<% end %> | ||
<% if schema.maximum %> | ||
- <%= schema.exclusive_maximum? ? 'Maximum (exclusive)' : 'Maximum' %>: `<%= schema.maximum %>` | ||
<% end %> | ||
<% end %> | ||
|
||
<% unless schema.max_properties.nil? %> | ||
- Maximum properties: `<%= schema.max_properties %>` | ||
<% end %> | ||
<% if schema.min_properties != 0 %> | ||
- Minimum properties: `<%= schema.min_properties %>` | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters