Skip to content

feat: include #[RequestParam] annotations in OpenAPI spec generation#105

Merged
usernane merged 1 commit intomainfrom
dev
May 3, 2026
Merged

feat: include #[RequestParam] annotations in OpenAPI spec generation#105
usernane merged 1 commit intomainfrom
dev

Conversation

@usernane
Copy link
Copy Markdown
Member

@usernane usernane commented May 3, 2026

Summary

OpenAPI spec generator now reads #[RequestParam] annotations and includes parameter definitions in the generated spec.

Motivation

toOpenAPI() generated specs with correct paths and methods but no parameter definitions, making Swagger UI less useful for API consumers. Fixes #100.

Changes

  • OperationObj: Added parameters and requestBody fields with serialization support.
  • WebService::toPathItemObj(): Reflects on #[RequestParam] annotations grouped by HTTP method:
    • GET/DELETE → parameters array (query params with name, type, required)
    • POST/PUT/PATCH → requestBody with application/x-www-form-urlencoded schema (properties, required array)
    • ParamType mapped to OpenAPI types (STRING→string, INT→integer, EMAIL→string+email format, URL→string+uri format)
  • Added OpenAPIGetPostService test service (mixed GET/POST with various param types).
  • Added OpenAPIRequestParamTest with 9 test cases.

How to Test / Verify

php vendor/bin/phpunit --configuration tests/phpunit10.xml --filter OpenAPIRequestParamTest
php vendor/bin/phpunit --configuration tests/phpunit10.xml  # full suite: 431 tests, 0 failures

Breaking Changes and Migration Steps

None. Previously empty operations now include parameter metadata. No existing fields are removed or changed.

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • The title of the pull request follows Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed)
  • I ran lint/cs-fixer (if applicable)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #100

@usernane usernane merged commit 38a7bbe into main May 3, 2026
6 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

❌ Patch coverage is 92.77108% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.32%. Comparing base (23ac100) to head (5b99eb5).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
WebFiori/Http/OpenAPI/OperationObj.php 75.00% 4 Missing ⚠️
WebFiori/Http/WebService.php 97.01% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #105      +/-   ##
============================================
+ Coverage     92.12%   92.32%   +0.19%     
- Complexity     1268     1292      +24     
============================================
  Files            39       39              
  Lines          3049     3128      +79     
============================================
+ Hits           2809     2888      +79     
  Misses          240      240              
Flag Coverage Δ
php-8.1 92.09% <91.89%> (+0.20%) ⬆️
php-8.2 92.16% <92.77%> (+0.20%) ⬆️
php-8.3 92.16% <92.77%> (+0.20%) ⬆️
php-8.4 92.16% <92.77%> (+0.20%) ⬆️
php-8.5 92.16% <92.77%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 3, 2026

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.

feat: OpenAPI spec generator should include #[RequestParam] annotations

1 participant