Skip to content

test: add XSD constraint and content parsing coverage (closes #2439)#2504

Open
chengyixu wants to merge 4 commits intoasyncapi:masterfrom
chengyixu:test/xsd-constraint-coverage
Open

test: add XSD constraint and content parsing coverage (closes #2439)#2504
chengyixu wants to merge 4 commits intoasyncapi:masterfrom
chengyixu:test/xsd-constraint-coverage

Conversation

@chengyixu
Copy link
Copy Markdown

Summary

Adds 20 new test cases to test/processors/XsdInputProcessor.spec.ts covering previously untested code paths identified in #2439.

Previously uncovered paths now covered:

  • parseSimpleContent — complexType with xs:simpleContent extension (e.g., PersonType with base string + attributes)
  • parseComplexContent — complexType with xs:complexContent extension including xs:sequence and attributes (Dog extends Animal)
  • parseSimpleType within elements — inline xs:simpleType restriction on element children
  • Pattern restrictions — xs:pattern on xs:simpleType
  • Length constraints — xs:minLength only, xs:maxLength only, and both together
  • Numeric constraints — xs:minInclusive only, xs:maxInclusive only, and both together
  • XsdSchema.toSchema edge cases — empty object input, schema targetNamespace/elementFormDefault/attributeFormDefault

New XSD fixture files:

File Purpose
simple-content.xsd PersonType using xs:simpleContent with extension + attribute
complex-content.xsd Dog extending Animal via xs:complexContent extension
pattern-restrictions.xsd EmailType, PasswordType, PercentageType, NonEmptyString, ShortLabel
inline-simple-type.xsd Product element with inline xs:simpleType restriction on child elements

Test count: 34 total (was 14), all passing.

Snapshots: 4 new snapshots added, 1 updated.

Closes #2439

🤖 Generated with Claude Code

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 29, 2026

Deploy Preview for modelina canceled.

Name Link
🔨 Latest commit 20ca8f9
🔍 Latest deploy log https://app.netlify.com/projects/modelina/deploys/69d51e2f1614b1000834f4dd

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@chengyixu
Copy link
Copy Markdown
Author

Hi! This PR adds comprehensive XSD constraint and content parsing test coverage. All CI checks are green (SonarCloud, Netlify, lint). Ready for review!

@chengyixu
Copy link
Copy Markdown
Author

Hi maintainers! All checks are passing. This adds 20 new XSD constraint tests covering parseSimpleContent, parseComplexContent, pattern/length/numeric constraints, and inline simpleType. Would love a review when you get a chance. Thanks!

chengyixu and others added 2 commits April 6, 2026 19:09
…i#2439)

Adds 20 new tests targeting previously uncovered code paths in
XsdSchema.ts and XsdInputProcessor.spec.ts:

- simpleContent extension/restriction parsing (parseSimpleContent)
- complexContent extension with sequence + attributes (parseComplexContent)
- pattern restriction on simpleType
- minLength / maxLength string constraints
- minInclusive / maxInclusive numeric constraints (each alone + combined)
- inline simpleType within element sequences
- XsdSchema.toSchema edge cases (empty object, schema attributes)

New XSD fixture files:
- simple-content.xsd  — PersonType with simpleContent extension
- complex-content.xsd — Dog extending Animal via complexContent
- pattern-restrictions.xsd — EmailType, PasswordType, PercentageType
- inline-simple-type.xsd — Product element with inline enum restriction

All 34 tests pass; 4 new snapshots captured.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace require() calls with ES import for fast-xml-parser and fix
prettier formatting issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chengyixu chengyixu force-pushed the test/xsd-constraint-coverage branch from 2e00207 to 229472e Compare April 6, 2026 11:11
@chengyixu
Copy link
Copy Markdown
Author

Hi maintainers! I've rebased this branch on the latest master and fixed the lint errors (replaced require() calls with ES import for fast-xml-parser, and fixed prettier formatting). All tests pass locally (34/34 tests, 10 snapshots). Could you please approve the CI workflow runs? They need first-time contributor approval to execute. Thank you!

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 7, 2026

@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 24029620313

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+1.1%) to 92.048%

Details

  • Coverage increased (+1.1%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 7421
Covered Lines: 6992
Line Coverage: 94.22%
Relevant Branches: 2765
Covered Branches: 2384
Branch Coverage: 86.22%
Branches in Coverage %: Yes
Coverage Strength: 369.6 hits per line

💛 - Coveralls

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.

test: missing XSD test coverage for constraints and content parsing

3 participants