Skip to content

Commit e9cab73

Browse files
authored
doc: standard documentation & CI setup (#1)
Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
1 parent 297e8c5 commit e9cab73

29 files changed

Lines changed: 1640 additions & 69 deletions

.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: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
Go source code scanner that parses Go packages and produces [Swagger 2.0](https://swagger.io/specification/v2/)
8+
(OpenAPI 2.0) specifications. It reads specially formatted comments (annotations) in Go source files
9+
and extracts API metadata — routes, parameters, responses, schemas, and more — to build a complete
10+
`spec.Swagger` document. Supports Go modules (go1.11+).
11+
12+
See [docs/MAINTAINERS.md](../docs/MAINTAINERS.md) for CI/CD, release process, and repo structure details.
13+
14+
### Package layout (single package)
15+
16+
| File | Contents |
17+
|------|----------|
18+
| `application.go` | `Options`, `Run` entry point, `appScanner` orchestration |
19+
| `parser.go` | `sectionedParser` — comment block parsing engine (title, description, annotations) |
20+
| `parser_helpers.go` | Helpers for tag/package filtering, value extraction |
21+
| `meta.go` | Swagger info block parsing (title, version, license, contact, etc.) |
22+
| `operations.go` | Operation (route handler) annotation parsing |
23+
| `parameters.go` | Parameter annotation parsing |
24+
| `responses.go` | Response annotation parsing |
25+
| `routes.go` | Route/path discovery and matching |
26+
| `route_params.go` | Route parameter extraction |
27+
| `schema.go` | Go type → Swagger schema conversion |
28+
| `enum.go` | Enum value extraction from Go constants |
29+
| `spec.go` | Spec-level helpers |
30+
| `regexprs.go` | Shared regular expressions for annotation parsing |
31+
| `assertions.go` | Test assertion helpers |
32+
33+
### Key API
34+
35+
- `Run(*Options) (*spec.Swagger, error)` — the main entry point: scan Go packages and produce a Swagger spec
36+
- `Options` — configuration: packages to scan, build tags, base swagger spec to overlay
37+
38+
### Dependencies
39+
40+
- `github.com/go-openapi/loads` — loading base Swagger specs
41+
- `github.com/go-openapi/spec` — Swagger 2.0 spec types
42+
- `github.com/go-openapi/swag` — string/JSON utilities
43+
- `golang.org/x/tools` — Go package loading (`packages.Load`)
44+
- `github.com/go-openapi/testify/v2` — test-only assertions
45+
46+
### Notable design decisions
47+
48+
- Uses `golang.org/x/tools/go/packages` for module-aware package loading.
49+
- Comment annotations follow the go-swagger convention (`swagger:route`, `swagger:operation`,
50+
`swagger:parameters`, `swagger:response`, `swagger:model`, etc.).
51+
- The scanner works on the AST level — it does not execute or compile the scanned code.

.claude/rules/contributions.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
paths:
3+
- "**/*"
4+
---
5+
6+
# Contribution rules (go-openapi)
7+
8+
Read `.github/CONTRIBUTING.md` before opening a pull request.
9+
10+
## Commit hygiene
11+
12+
- Every commit **must** be DCO signed-off (`git commit -s`) with a real email address.
13+
PGP-signed commits are appreciated but not required.
14+
- Agents may be listed as co-authors (`Co-Authored-By:`) but the commit **author must be the human sponsor**.
15+
We do not accept commits solely authored by bots or agents.
16+
- Squash commits into logical units of work before requesting review (`git rebase -i`).
17+
18+
## Linting
19+
20+
Before pushing, verify your changes pass linting against the base branch:
21+
22+
```sh
23+
golangci-lint run --new-from-rev master
24+
```
25+
26+
Install the latest version if you don't have it:
27+
28+
```sh
29+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
30+
```
31+
32+
## Problem statement
33+
34+
- Clearly describe the problem the PR solves, or reference an existing issue.
35+
- PR descriptions must not be vague ("fix bug", "improve code") — explain *what* was wrong and *why* the change is correct.
36+
37+
## Tests are mandatory
38+
39+
- Every bug fix or feature **must** include tests that demonstrate the problem and verify the fix.
40+
- The only exceptions are documentation changes and typo fixes.
41+
- Aim for at least 80% coverage of your patch.
42+
- Run the full test suite before submitting:
43+
44+
For mono-repos:
45+
```sh
46+
go test work ./...
47+
```
48+
49+
For single module repos:
50+
```sh
51+
go test ./...
52+
```

0 commit comments

Comments
 (0)