Skip to content

refactor: built in openapi generator#58

Merged
akfaiz merged 20 commits into
mainfrom
refactor/builtin-generator
May 9, 2026
Merged

refactor: built in openapi generator#58
akfaiz merged 20 commits into
mainfrom
refactor/builtin-generator

Conversation

@akfaiz
Copy link
Copy Markdown
Member

@akfaiz akfaiz commented May 9, 2026

Description

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactor / code quality
  • Other (describe):

Checklist

  • make check passes locally (sync + tidy + lint + test)
  • Tests added or updated to cover the change
  • Golden files updated if spec output changed (make test-update)
  • Relevant documentation updated (README, adapter README, etc.)
  • Commit messages follow Conventional Commits

Notes for Reviewers

Copy link
Copy Markdown

@llamapreview llamapreview Bot left a comment

Choose a reason for hiding this comment

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

AI Code Review by LlamaPReview

🎯 TL;DR & Recommendation

Recommendation: Request Changes

This PR modernizes the OpenAPI generator to use a built-in model and reflection, but introduces a compilation error in an internal mapper file due to a renamed type (openapi.OAuthFlowsImplicitopenapi.OAuthFlow), and leaves CONNECT method support inconsistently gated across adapters.

📄 Documentation Diagram

This diagram documents the new OpenAPI generation flow using the built-in generator with reflection.

sequenceDiagram
    participant Client
    participant Router as spec.Router
    participant Gen as Generator
    participant Reflector as Reflector
    participant Doc as openapi.Document
    Client->>Router: NewRouter(opts...)
    Router->>Gen: create generator
    Client->>Router: Post(path, opts...)
    Router->>Gen: Register route
    Client->>Router: Get(path, opts...)
    Router->>Gen: Register route
    Client->>Router: MarshalYAML()
    Router->>Gen: buildOnce()
    Gen->>Reflector: reflect schemas from Go types
    Reflector-->>Gen: *openapi.Schema
    Gen->>Doc: build OpenAPI document
    note over Router,Doc: PR replaces external swaggest library<br/>with owned OpenAPI model and reflector
    Router-->>Client: YAML/JSON output
Loading

🌟 Strengths

  • Solid golden-file test updates ensuring deterministic output changes are reviewed.
Priority File Category Impact Summary Anchors
P1 adapter/chiopenapi/router_test.go Bug Stale OAuthFlowsImplicit type blocks compilation path:internal/mapper/openapi3.go
P2 adapter/chiopenapi/router.go Architecture CONNECT gating not applied to other adapters
P2 Makefile Testing Fragile coverage aggregation, less readable output
P2 adapter/chiopenapi/router_test.go Testing Raw byte diff makes tests fragile to formatting

🔍 Notable Themes

  • Inconsistent CONNECT version gating: Only Chi adapter checks openapi.Version320 before skipping CONNECT; other adapters silently ignore it with OpenAPI 3.2.
  • Test fragility: Replacing semantic YAML comparison with byte comparison will cause false-positive failures on formatting changes.

📈 Risk Diagram

This diagram illustrates the stale mapper reference risk introduced by the type rename.

sequenceDiagram
    participant Test as Test (router_test.go)
    participant Mapper as internal/mapper/openapi3.go
    participant OpenAPIPkg as openapi package
    Test->>OpenAPIPkg: uses openapi.OAuthFlow (new type)
    OpenAPIPkg-->>Test: compiles fine
    Mapper->>OpenAPIPkg: references openapi.OAuthFlowsImplicit (old type)
    OpenAPIPkg-->>Mapper: type not found – compile error
    note over Mapper: R1(P1): Stale reference to removed type<br/>breaks build of internal/mapper
Loading

💡 Have feedback? We'd love to hear it in our GitHub Discussions.
✨ This review was generated by LlamaPReview Advanced, which is free for all open-source projects. Learn more.

Comment thread adapter/chiopenapi/router_test.go
Comment thread adapter/chiopenapi/router.go
Comment thread Makefile
Comment thread adapter/chiopenapi/router_test.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

@akfaiz akfaiz merged commit 5b20493 into main May 9, 2026
5 of 6 checks passed
@akfaiz akfaiz deleted the refactor/builtin-generator branch May 13, 2026 04:54
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.

echoopenapi adaptor breaks with path parameters when request option is missing

1 participant