Skip to content

Conversation

@ewaostrowska
Copy link
Contributor

Summary

Adds minimal bug reproduction tests for issue #4341.

Problem

After replacing required with requiredMode in #4286, the issue #3438 has reappeared. When using @ArraySchema with requiredMode on arraySchema, the field is not marked as required in the generated schema.

Tests Added

Test 1: testArraySchemaRequiredMode()

  • Reproduces the bug where ArraySchema.arraySchema.requiredMode doesn't work
  • Expected: Field 'addresses' should be in required array
  • Actual: Required mode on arraySchema is ignored

Test 2: testWorkaround()

  • Validates the workaround using schema.requiredMode
  • Shows that placing requiredMode on schema instead works correctly

Expected Behavior

@ArraySchema(
    arraySchema = @Schema(requiredMode = RequiredMode.REQUIRED)
)
private List<String> addresses;

Should generate:

{
  "Person": {
    "required": ["addresses"]
  }
}

Current Workaround

@ArraySchema(
    arraySchema = @Schema(description = "The person"),
    schema = @Schema(requiredMode = RequiredMode.REQUIRED)
)
private List<String> addresses;

References

Closes #4341
Related to #3438, #4286

Checklist

  • Minimal bug reproduction tests
  • Tests compile successfully
  • Tests demonstrate the bug
  • Tests show working workaround

- Test 1: Reproduces ArraySchema.arraySchema.requiredMode not working
- Test 2: Validates workaround using schema.requiredMode
- Minimal test models
- Focused on issue reproduction only

See: swagger-api#4341
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.

Whether an array is required or not should be controlled by ArraySchema.arraySchema.requiredMode instead of ArraySchema.schema.requiredMode

1 participant