Skip to content

feat: NewOpenAPIService OASVersion dispatch + parameter format support - #126

Merged
emicklei merged 1 commit into
emicklei:v2from
erraggy:feature/oastools-param-format
Dec 25, 2025
Merged

feat: NewOpenAPIService OASVersion dispatch + parameter format support#126
emicklei merged 1 commit into
emicklei:v2from
erraggy:feature/oastools-param-format

Conversation

@erraggy

@erraggy erraggy commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

Context

This PR is a follow-up to PR#125 which introduced the oastools builder integration. It addresses feedback from the maintainer regarding NewOpenAPIService behavior and adds parameter format support that achieves feature parity with the legacy BuildSwagger path.


Summary

NewOpenAPIService Enhancement

  • NewOpenAPIService now dispatches based on Config.OASVersion:
    • OAS 3.x versions → uses BuildOAS3
    • OAS 2.0 → uses BuildOAS2
    • Unset/default → falls back to legacy BuildSwagger

Parameter Format Support

  • Add support for param.DataFormat() using oastools v1.33.0 WithParamFormat
  • Previously, formats like "uuid", "date", "date-time", and "int64" were ignored
  • Now properly propagated to the OpenAPI spec for both OAS 2.0 and 3.x output

Code Quality Improvements

  • BuildOAS2/BuildOAS3 now call Config.Validate() to catch configuration errors early
  • Extract shared response option building into buildResponseOptions helper
  • Add formatBinary constant to satisfy goconst linter

Changes

  • Upgrade oastools dependency to v1.33.0
  • Implement WithParamFormat in mapParameter() function
  • Add comprehensive tests for parameter format in both OAS 2.0 and OAS 3.x output
  • Improve error handling with early config validation

Test plan

  • All existing tests pass
  • New tests verify parameter format for uuid, date, date-time, int64
  • Tests for NewOpenAPIService OAS version dispatching
  • Linter passes with no issues
  • Coverage: 72.9%

🤖 Generated with Claude Code

- NewOpenAPIService now dispatches based on Config.OASVersion
- Address PR review feedback for error handling and feature parity
- Add parameter type/format support using oastools v1.33.0 WithParamFormat
- Achieves feature parity with legacy BuildSwagger for parameter format handling
- Upgrade oastools dependency to v1.33.0
- Add formatBinary constant to satisfy goconst linter

The parameter format feature fills a gap where param.DataFormat("date") was
previously ignored by the oastools builder path. Now formats like "uuid",
"date", "date-time", and "int64" are properly propagated to the OpenAPI spec.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@emicklei
emicklei merged commit 9d262be into emicklei:v2 Dec 25, 2025
1 check passed
@erraggy
erraggy deleted the feature/oastools-param-format branch December 25, 2025 15:38
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