Skip to content

Commit

Permalink
refactor: remove unnecessary handling of isArray case (#13)
Browse files Browse the repository at this point in the history
* Remove unnecessary handling of isArray case

additionalProperties and additionalItems are allowed to be boolean or an object, never an array.

* Add at least one usage of additionalProperties to sample schema

Note that additionalProperties defaults to true, hence why we're adding it as false here
  • Loading branch information
jamescrowley authored Apr 28, 2020
1 parent b05889d commit bf7388a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions partials/schema-prop.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
{% endif %}
{% endif %}

{% if prop.additionalItems() | isArray or prop.additionalItems() === true or prop.additionalItems() === undefined %}
{% if prop.additionalItems() === true or prop.additionalItems() === undefined %}
<p class="pl-6 mb-2 mt-4 text-xs text-grey-darker">Additional items are allowed.</p>
{% elif prop.additionalItems() === false %}
<p class="pl-6 mb-2 mt-4 text-xs text-grey-darker">Additional items are NOT allowed.</p>
Expand All @@ -162,7 +162,7 @@
{% endif %}

{% if prop.type() === 'object' %}
{% if prop.additionalProperties() | isArray or prop.additionalProperties() === true or prop.additionalProperties() === undefined or prop.additionalProperties() === null %}
{% if prop.additionalProperties() === true or prop.additionalProperties() === undefined or prop.additionalProperties() === null %}
<p class="pl-6 mb-2 mt-4 text-xs text-grey-darker">Additional properties are allowed.</p>
{% elif prop.additionalProperties() === false %}
<p class="pl-6 mb-2 mt-4 text-xs text-grey-darker">Additional properties are <strong>NOT</strong> allowed.</p>
Expand Down
1 change: 1 addition & 0 deletions test/spec/asyncapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ components:
x-pi: false
sentAt:
$ref: "#/components/schemas/sentAt"
additionalProperties: false
turnOnOffPayload:
type: object
properties:
Expand Down

0 comments on commit bf7388a

Please sign in to comment.