Skip to content

Fixes issue 57: Empty object schemas were incorrectly flagged as incomplete#37

Merged
prasanthcisco merged 1 commit intomainfrom
empty-arrays-incomplete-contract
Feb 18, 2026
Merged

Fixes issue 57: Empty object schemas were incorrectly flagged as incomplete#37
prasanthcisco merged 1 commit intomainfrom
empty-arrays-incomplete-contract

Conversation

@prasanthcisco
Copy link
Collaborator

Issue:
Empty object schemas were incorrectly flagged as incomplete when they had type: "object", no properties, and additionalProperties: false.

Rule affected:
general-schema-definition (Contract Completeness / Doc Completeness)

Fix:
Treat object schemas with additionalProperties: false as complete, since they explicitly define an empty object contract {}.

Problem

Schemas like the following were reported with "properties missing for object schema":

{
  "type": "object",
  "example": {},
  "description": "Response for a successful association/disassociation of connections to a policy",
  "additionalProperties": false
}

This is a valid OpenAPI/JSON Schema: additionalProperties: false means no extra properties are allowed, so the only valid value is {}. Such schemas are commonly used for success acknowledgments, DELETE responses, and bulk-update responses.

Solution

updates to functions/completedSchema.js

  1. Allow empty objects when additionalProperties: false
    Before returning the error, the function now returns early (no error) when targetVal.additionalProperties === false.

  2. Null-safe guard
    Added a check for targetVal == null so that null and other non-object inputs do not cause runtime errors and are treated as “skip” (return undefined).

Tests

  • Pass → Empty object with additionalProperties: false (with/without description, example, and v1AddOrUpdatePolicyConnectionsResponse-style); object with properties: {} and additionalProperties: false.
  • Report error → Plain type: "object" with no additionalProperties: false; additionalProperties: true; additionalProperties as a schema object.
  • Edge cases: Non-object inputs (string, number, null) pass (return undefined).
  • general-schema-definition “should pass with provided schema” runs against positive.json, which now includes the /ack path with an empty-object schema.

@prasanthcisco prasanthcisco merged commit df21c73 into main Feb 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments