Skip to content

Commit 3b063c0

Browse files
authored
chore: updated dependencies (removed mongodb indirect dependency) (#399)
ci: setup mono-repo shared workflows test: adopted testify/v2 generics doc: relinted godoc doc: relinted markdown chore: relinted code base Signed-off-by: Frederic BIDON <[email protected]>
1 parent f9c40d3 commit 3b063c0

File tree

125 files changed

+1764
-1255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1764
-1255
lines changed

.claude/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
plans/
2+
skills/
3+
commands/
4+
agents/
5+
hooks/

.claude/CLAUDE.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
`github.com/go-openapi/runtime` is the runtime library for the go-openapi toolkit.
8+
It provides HTTP client and server components used by code generated by [go-swagger](https://github.com/go-swagger/go-swagger)
9+
and for untyped OpenAPI/Swagger API usage.
10+
11+
See [docs/MAINTAINERS.md](../docs/MAINTAINERS.md) for CI/CD, release process, and repo structure details.
12+
13+
### Modules and Package layout
14+
15+
This is a mono-repo with a `go.work` workspace containing two modules:
16+
17+
| Module | Purpose |
18+
|--------|---------|
19+
| `.` (root) | Core runtime library |
20+
| `client-middleware/opentracing` | Optional OpenTracing middleware for client transport |
21+
22+
Packages in the root module:
23+
24+
| Package | Contents |
25+
|---------|----------|
26+
| `runtime` (root) | Core interfaces (`Consumer`, `Producer`, `Authenticator`, `Authorizer`, `OperationHandler`), content-type handlers (JSON, XML, CSV, text, bytestream), HTTP request/response helpers |
27+
| `client` | HTTP client transport: `Runtime` with TLS, timeouts, proxy, keepalive, OpenTelemetry tracing |
28+
| `middleware` | Server-side request lifecycle: routing, content negotiation, parameter binding, validation, security, Swagger UI / RapiDoc serving |
29+
| `middleware/denco` | Internal path-pattern router |
30+
| `middleware/header` | HTTP header parsing utilities |
31+
| `middleware/untyped` | Untyped (reflection-based) API request/response handling |
32+
| `security` | Auth scheme implementations: Basic, API Key, Bearer/OAuth2 (with `*Ctx` context-aware variants) |
33+
| `logger` | `Logger` interface with `Printf`/`Debugf`; debug enabled via `SWAGGER_DEBUG` or `DEBUG` env vars |
34+
| `flagext` | CLI flag extensions (e.g. `ByteSize`) |
35+
| `yamlpc` | YAML producer/consumer support |
36+
| `internal/testing` | Internal test utilities |
37+
38+
### Key API
39+
40+
Core interfaces (root package, `interfaces.go`):
41+
42+
- `Consumer` / `ConsumerFunc` — bind request body to a Go value
43+
- `Producer` / `ProducerFunc` — serialize a Go value to the response body
44+
- `Authenticator` / `AuthenticatorFunc` — authenticate a request, return a principal
45+
- `Authorizer` / `AuthorizerFunc` — authorize a principal for a request
46+
- `OperationHandler` / `OperationHandlerFunc` — handle a matched API operation
47+
- `Validatable`, `ContextValidatable` — custom validation hooks for generated types
48+
49+
Built-in content-type factories: `JSONConsumer()`, `JSONProducer()`, `XMLConsumer()`, `XMLProducer()`,
50+
`CSVConsumer()`, `CSVProducer()`, `TextConsumer()`, `TextProducer()`,
51+
`ByteStreamConsumer()`, `ByteStreamProducer()`
52+
53+
Client transport (`client` package):
54+
55+
- `Runtime` — configurable HTTP transport (TLS, auth, timeout, OpenTelemetry)
56+
- `TLSClientOptions` — mTLS / custom CA configuration
57+
58+
Server middleware (`middleware` package):
59+
60+
- `Context` — request lifecycle manager (routes, binds, validates, authenticates, executes)
61+
- `NewRouter()` — builds a router from an analyzed OpenAPI spec
62+
- `Spec()`, `SwaggerUI()`, `RapiDoc()` — spec and documentation serving middleware
63+
64+
### Dependencies
65+
66+
Key direct dependencies (`go.mod`):
67+
68+
| Dependency | Role |
69+
|------------|------|
70+
| `go-openapi/analysis` | OpenAPI spec analysis |
71+
| `go-openapi/errors` | Structured API error types |
72+
| `go-openapi/loads` | OpenAPI spec loading |
73+
| `go-openapi/spec` | OpenAPI spec model types |
74+
| `go-openapi/strfmt` | String format registry (date-time, UUID, etc.) |
75+
| `go-openapi/swag/*` | Utilities: conv, fileutils, jsonutils, stringutils |
76+
| `go-openapi/validate` | Spec-based validation |
77+
| `go-openapi/testify/v2` | Test assertions (zero-dep fork of stretchr/testify) |
78+
| `go.opentelemetry.io/otel` | OpenTelemetry tracing |
79+
| `docker/go-units` | Human-readable size parsing |
80+
81+
### Notable historical design decisions
82+
83+
- **Functional adapter pattern**: every core interface has a companion `*Func` type
84+
(e.g. `ConsumerFunc`) so handlers can be plain functions or full structs.
85+
- **Consumer/Producer split**: request deserialization and response serialization are
86+
decoupled behind separate interfaces, allowing per-content-type pluggability.
87+
- **Context-aware auth variants**: security functions come in pairs (`BasicAuth` / `BasicAuthCtx`)
88+
to support both legacy and context-propagating call paths.
89+
- **Middleware pipeline**: server processing flows through
90+
Router → Binder → Validator → Security → OperationExecutor → Responder,
91+
each stage composable via `middleware.Builder`.
92+
- **OpenTracing kept in a separate module**: avoids pulling the OpenTracing dependency
93+
into consumers that only need the core runtime or use OpenTelemetry directly.

.claude/rules/go-conventions.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
paths:
3+
- "**/*.go"
4+
---
5+
6+
# Code conventions (go-openapi)
7+
8+
- All files must have SPDX license headers (Apache-2.0).
9+
- Go version policy: support the 2 latest stable Go minor versions.
10+
- Commits require DCO sign-off (`git commit -s`).

.claude/rules/linting.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
paths:
3+
- "**/*.go"
4+
---
5+
6+
# Linting conventions (go-openapi)
7+
8+
```sh
9+
golangci-lint run
10+
```
11+
12+
Config: `.golangci.yml` — posture is `default: all` with explicit disables.
13+
See `docs/STYLE.md` for the rationale behind each disabled linter.
14+
15+
Key rules:
16+
- Every `//nolint` directive **must** have an inline comment explaining why.
17+
- Prefer disabling a linter over scattering `//nolint` across the codebase.

.claude/rules/testing.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
paths:
3+
- "**/*_test.go"
4+
---
5+
6+
# Testing conventions (go-openapi)
7+
8+
## Running tests
9+
10+
**Single module repos:**
11+
12+
```sh
13+
go test ./...
14+
```
15+
16+
**Mono-repos (with `go.work`):**
17+
18+
```sh
19+
# All modules
20+
go test work ./...
21+
22+
# Single module
23+
go test ./conv/...
24+
```
25+
26+
Note: in mono-repos, plain `go test ./...` only tests the root module.
27+
The `work` pattern expands to all modules listed in `go.work`.
28+
29+
CI runs tests on `{ubuntu, macos, windows} x {stable, oldstable}` with `-race` via `gotestsum`.
30+
31+
## Fuzz tests
32+
33+
```sh
34+
# List all fuzz targets
35+
go test -list Fuzz ./...
36+
37+
# Run a specific target (go test -fuzz cannot span multiple packages)
38+
go test -fuzz=Fuzz -run='FuzzTargetName$' -fuzztime=1m30s ./package
39+
```
40+
41+
Fuzz corpus lives in `testdata/fuzz/` within each package. CI runs each fuzz target for 1m30s
42+
with a 5m minimize timeout.
43+
44+
## Test framework
45+
46+
`github.com/go-openapi/testify/v2` — a zero-dep fork of `stretchr/testify`.
47+
Because it's a fork, `testifylint` does not work.

0 commit comments

Comments
 (0)