Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7225eec
refactor: rebuild core generator, reflector, and validator
akfaiz May 9, 2026
6db131c
refactor(adapter): align adapters with new spec core
akfaiz May 9, 2026
5a61237
docs: refresh README and lint workflow
akfaiz May 9, 2026
f12ed8b
feat: remove default jsonSchemaDialect
akfaiz May 9, 2026
b9e7e57
feat: change ordering of root openapi
akfaiz May 9, 2026
48cb908
fix: harden path and method generation
akfaiz May 9, 2026
6d1e359
feat: auto inject missing path parameter
akfaiz May 9, 2026
f00c9f3
feat: remove gotestsum and adjust coverage mechanism
akfaiz May 9, 2026
eedd3b4
fix: failed lint at pipeline and remove global dto
akfaiz May 9, 2026
657dc73
test: standarize adapter test to use testutil
akfaiz May 9, 2026
2a4aabf
chore: bump version adapter dependency
akfaiz May 9, 2026
9c7e4ec
test: fix failed test at adapter and adjust merge coverage mechanism
akfaiz May 9, 2026
5607b91
ci: remove install tools at matrix test
akfaiz May 9, 2026
95a49b7
ci: change run coverage to go1.25
akfaiz May 9, 2026
7413a1d
ci: remove test and quailty check
akfaiz May 9, 2026
65367ad
docs: adjust some go doc comments and readme.md
akfaiz May 9, 2026
4f0ba26
feat: remove httprouter at list supported adapters
akfaiz May 9, 2026
0d66255
test: fix issue at merge coverage command and increase code coverage
akfaiz May 9, 2026
b6152fa
docs: adjust project documentation to more clear about function for s…
akfaiz May 9, 2026
0751c8d
feat: add prefix package name for default def name
akfaiz May 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: make install-tools

- name: ✅ Run Quality Checks
run: make check
run: make sync tidy lint

# ========================================
# Test Matrix
Expand Down Expand Up @@ -77,18 +77,16 @@ jobs:
check-latest: true
cache: true # Handles module/build cache

- name: 🔧 Install Tools
run: make install-tools

- name: 🧪 Run Tests
if: matrix.go-version != '1.25'
run: make test

- name: 📊 Generate Coverage Report
if: matrix.go-version == '1.23'
if: matrix.go-version == '1.25'
run: make testcov

- name: 📈 Upload Coverage Report
if: matrix.go-version == '1.23'
if: matrix.go-version == '1.25'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down Expand Up @@ -116,4 +114,4 @@ jobs:
echo "Tests failed"
exit 1
fi
echo "All CI checks passed! 🎉"
echo "All CI checks passed! 🎉"
78 changes: 46 additions & 32 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ formatters:
# with the given prefixes are grouped after 3rd-party packages.
# Default: []
local-prefixes:
- github.com/my/project
- github.com/oaswrap/spec

golines:
# Target maximum line length.
# Default: 100
max-len: 120
# Keep struct tag literals readable; tag padding creates very wide OpenAPI reflection fixtures.
reformat-tags: false

linters:
enable:
Expand All @@ -38,8 +40,9 @@ linters:
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- canonicalheader # checks whether net/http.Header uses canonical header
- clickhouselint # detects common mistakes with the ClickHouse native Go driver API
- copyloopvar # detects places where loop variables are copied (Go 1.22+)
- cyclop # checks function and package cyclomatic complexity
#- cyclop # overlaps with gocognit and gocyclo; too noisy for validation-heavy code
- depguard # checks if package imports are in a list of acceptable packages
- dupl # tool for code clone detection
- durationcheck # checks for two durations multiplied together
Expand All @@ -51,16 +54,17 @@ linters:
- exptostd # detects functions from golang.org/x/exp/ that can be replaced by std functions
- fatcontext # detects nested contexts in loops
- forbidigo # forbids identifiers
- funcorder # checks the order of functions, methods, and constructors
#- funcorder # style-only and fights natural organization in small packages
- funlen # tool for detection of long functions
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
- gochecknoglobals # checks that no global variables exist
#- gochecknoglobals # too strict for regex vars, sentinel errors, and test flags
- gochecknoinits # checks that no init functions are present in Go code
- gochecksumtype # checks exhaustiveness on Go "sum types"
- gocognit # computes and checks the cognitive complexity of functions
- goconst # finds repeated strings that could be replaced by a constant
#- goconst # finds repeated strings that could be replaced by a constant
- gocritic # provides diagnostics that check for bugs, performance and style issues
- gocyclo # computes and checks the cyclomatic complexity of functions
#- gocyclo # overlaps with gocognit; gocognit gives better signal here
- godoclint # checks Golang's documentation practice
- godot # checks if comments end in a period
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- goprintffuncname # checks that printf-like functions are named with f at the end
Expand All @@ -69,10 +73,12 @@ linters:
- iface # checks the incorrect use of interfaces, helping developers avoid interface pollution
- ineffassign # detects when assignments to existing variables are not used
- intrange # finds places where for loops could make use of an integer range
- iotamixing # checks if iotas are being used in const blocks with other non-iota declarations
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
- makezero # finds slice declarations with non-zero initial length
- mirror # reports wrong mirror patterns of bytes/strings usage
- mnd # detects magic numbers
#- mnd # too noisy for OpenAPI versions, status codes, and schema/domain literals
- modernize # suggests simplifications to Go code, using modern language and library features
- musttag # enforces field tags in (un)marshaled structs
- nakedret # finds naked returns in functions greater than a specified function length
- nestif # reports deeply nested if statements
Expand All @@ -83,7 +89,8 @@ linters:
- nolintlint # reports ill-formed or insufficient nolint directives
- nonamedreturns # reports all named returns
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
- perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative
#- paralleltest # detects missing usage of t.Parallel() method in your Go test
#- perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative
- predeclared # finds code that shadows one of Go's predeclared identifiers
- promlinter # checks Prometheus metrics naming via promlint
- protogetter # reports direct reads from proto message fields when getters should be used
Expand All @@ -97,10 +104,11 @@ linters:
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
- testableexamples # checks if examples are testable (have an expected output)
- testifylint # checks usage of github.com/stretchr/testify
- testpackage # makes you use a separate _test package
#- testpackage # makes you use a separate _test package
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- unqueryvet # detects SELECT * in SQL queries and SQL builders, encouraging explicit column selection
- unused # checks for unused constants, variables, functions and types
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- usetesting # reports uses of functions with replacement inside the testing package
Expand Down Expand Up @@ -132,18 +140,16 @@ linters:
#- err113 # [too strict] checks the errors handling expressions
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
#- gomodguard # [use more powerful depguard] allow and block lists linter for direct Go module dependencies
#- gomodguard_v2: [use more powerful depguard] allow and blocklist linter for direct Go module dependencies
#- gosmopolitan # reports certain i18n/l10n anti-patterns in your Go codebase
#- grouper # analyzes expression groups
#- importas # enforces consistent import aliases
#- lll # [replaced by golines] reports long lines
#- maintidx # measures the maintainability index of each function
#- misspell # [useless] finds commonly misspelled English words in comments
#- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
#- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test
#- tagliatelle # checks the struct tags
#- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
#- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines
#- wsl_v5 # [too strict and mostly code is not more readable] add or remove empty lines

# All settings can be found here https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
Expand Down Expand Up @@ -282,7 +288,7 @@ linters:
gocognit:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 20
min-complexity: 30

gocritic:
# Settings passed to gocritic.
Expand All @@ -298,6 +304,17 @@ linters:
# Default: true
skipRecvDeref: false

godoclint:
# List of rules to enable in addition to the default set.
# Default: empty
enable:
# Assert no unused link in godocs.
# https://github.com/godoc-lint/godoc-lint?tab=readme-ov-file#no-unused-link
- no-unused-link
# Require proper doc links to standard library declarations where applicable.
# https://github.com/godoc-lint/godoc-lint?tab=readme-ov-file#require-stdlib-doclink
- require-stdlib-doclink

govet:
# Enable all analyzers.
# Default: false
Expand All @@ -312,7 +329,7 @@ linters:
shadow:
# Whether to be strict about shadowing; can be noisy.
# Default: false
strict: true
strict: false

inamedparam:
# Skips check for interface methods with only a single parameter.
Expand Down Expand Up @@ -374,21 +391,15 @@ linters:
- github.com/jmoiron/sqlx

sloglint:
# Enforce not using global loggers.
# Values:
# - "": disabled
# - "all": report all global loggers
# - "default": report only the default slog logger
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-global
# Default: ""
# Report the use of global loggers.
# https://github.com/go-simpler/sloglint#no-global-logger
# Values: "all", "default"
# Default: "" (disabled)
no-global: all
# Enforce using methods that accept a context.
# Values:
# - "": disabled
# - "all": report all contextless calls
# - "scope": report only if a context exists in the scope of the outermost function
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#context-only
# Default: ""
# Report the use of functions without a context.Context.
# https://github.com/go-simpler/sloglint#context-only
# Values: "all", "scope"
# Default: "" (disabled)
context: scope

staticcheck:
Expand All @@ -415,16 +426,14 @@ linters:
exclusions:
# Log a warning if an exclusion rule is unused.
# Default: false
warn-unused: true
warn-unused: false
# Predefined exclusion rules.
# Default: []
presets:
- std-error-handling
- common-false-positives
# Excluding configuration per-path, per-linter, per-text and per-source.
rules:
- text: 'local replacement are not allowed'
linters: [ gomoddirectives ]
- source: 'TODO'
linters: [ godot ]
- text: 'should have a package comment'
Expand All @@ -437,6 +446,11 @@ linters:
- text: 'comment on exported \S+ \S+ should be of the form ".+"'
source: '// ?(nolint|TODO)'
linters: [ revive, staticcheck ]
- path: 'internal/validate/.*\.go'
text: 'stutters; consider calling this'
linters: [ revive ]
- text: 'local replacement are not allowed'
linters: [ gomoddirectives ]
- path: '_test\.go'
linters:
- bodyclose
Expand All @@ -446,4 +460,4 @@ linters:
- goconst
- gosec
- noctx
- wrapcheck
- wrapcheck
43 changes: 43 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Repository Guidelines

## Project Structure & Module Organization

This repository is a Go workspace for `github.com/oaswrap/spec`. Core package files live at the repository root and in `openapi/`, `option/`, `pkg/`, and `internal/`. Router adapters are separate modules under `adapter/<framework>openapi/`, each with its own examples, tests, and `go.mod`. Runnable examples live in `examples/` and adapter `example/` directories. Golden YAML fixtures and expected OpenAPI output live in `testdata/` and adapter `testdata/` directories.

## Build, Test, and Development Commands

- `make install-tools`: installs `golangci-lint`.
- `make test`: runs core and adapter tests with `go test`.
- `make test-adapter`: runs only adapter module tests.
- `make test-update`: regenerates golden files when output changes intentionally.
- `make testcov` / `make testcov-html`: produces coverage reports in `coverage/`.
- `make lint`: runs `golangci-lint` for core and adapters.
- `make tidy`: runs `go mod tidy` across core, adapters, and examples.
- `make sync`: updates the Go workspace.
- `make check`: runs sync, tidy, lint, and all tests.

Use `go test ./... -run TestName` for focused core tests, or run the same command inside an adapter module for adapter-specific work.

## Coding Style & Naming Conventions

Use standard Go formatting (`gofmt`) and idiomatic Go naming. Package names are short lowercase names such as `openapi`, `option`, or `parser`. Test files must use the `_test.go` suffix. Adapter directories follow the `<framework>openapi` pattern, for example `fiberopenapi` and `ginopenapi`. Keep public APIs documented when exported names are not self-explanatory.

## Testing Guidelines

Tests use Go's standard `testing` package, with golden-file coverage for generated OpenAPI YAML. Add or update tests for behavior changes, especially changes to route registration, schema reflection, options, or adapter output. When running `make test-update`, review all generated fixture diffs before committing.

## Commit & Pull Request Guidelines

Use Conventional Commits:

```text
feat: add response header option
fix: handle empty path group correctly
docs: clarify WithSecurity usage
```

Accepted types include `feat`, `fix`, `docs`, `style`, `refactor`, `test`, and `chore`. Keep commits focused. Pull requests should describe what changed, why it changed, affected modules or adapters, related issues, and tests run. Include fixture updates when generated output changes.

## Agent-Specific Instructions

Follow existing patterns before adding abstractions. Changes to core generation may require adapter and golden-file updates. Do not modify release tags, generated coverage reports, or unrelated module files unless the task explicitly requires it.
93 changes: 0 additions & 93 deletions CLAUDE.md

This file was deleted.

Loading
Loading