Skip to content

Commit 4e5bfe0

Browse files
fredbiclaude
andauthored
docs: update documentation to reflect the new diff package (#180)
Signed-off-by: Frédéric BIDON <fredbi@yahoo.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e3e9b78 commit 4e5bfe0

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.claude/CLAUDE.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
Go library for analyzing, flattening, merging (mixin), and fixing
7+
Go library for analyzing, diffing, flattening, merging (mixin), and fixing
88
[Swagger 2.0](https://swagger.io/specification/v2/) specifications. Built on top of
99
`go-openapi/spec`, it is a central utility in the go-swagger ecosystem for code generation
1010
and validation tooling.
@@ -28,6 +28,17 @@ See [docs/MAINTAINERS.md](../docs/MAINTAINERS.md) for CI/CD, release process, an
2828
| `errors.go` | Sentinel errors (`ErrAnalysis`, `ErrNoSchema`) and error factory functions |
2929
| `debug.go` | Debug logger wired to `SWAGGER_DEBUG` env var |
3030

31+
### `diff/` package
32+
33+
| File | Contents |
34+
|------|----------|
35+
| `diff/spec_analyser.go` | `SpecAnalyser` — walks two specs and collects differences by endpoint, schema, parameter, response |
36+
| `diff/reporting.go` | `Compare(spec1, spec2 *spec.Swagger)` — top-level entry point returning `SpecDifferences` |
37+
| `diff/compatibility.go` | Backward-compatibility classification of each change |
38+
| `diff/spec_difference.go` | `SpecDifference`, `SpecDifferences`, `SpecChangeCode` — diff result types |
39+
| `diff/schema.go` | Schema-level diffing (properties, enums, allOf) |
40+
| `diff/checks.go` | Primitive comparisons: `CompareEnums()`, `CompareProperties()`, numeric range checks |
41+
3142
### Internal packages (`internal/`)
3243

3344
| Package | Contents |
@@ -47,6 +58,7 @@ See [docs/MAINTAINERS.md](../docs/MAINTAINERS.md) for CI/CD, release process, an
4758
- `Schema(SchemaOpts) (*AnalyzedSchema, error)` — classify a schema (array, map, tuple, base type, etc.)
4859
- `Flatten(FlattenOpts) error` — flatten/expand a spec (inline schemas → definitions, remote refs → local)
4960
- `Mixin(primary, mixins...) []string` — merge multiple specs, returning collision warnings
61+
- `diff.Compare(spec1, spec2 *spec.Swagger) (SpecDifferences, error)` — compare two specs and report changes with compatibility info
5062
- `FixEmptyResponseDescriptions(*spec.Swagger)` — patch empty response descriptions
5163

5264
### Dependencies

.github/copilot-instructions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Project Overview
44

5-
Go library for analyzing, flattening, merging (mixin), and fixing
5+
Go library for analyzing, diffing, flattening, merging (mixin), and fixing
66
[Swagger 2.0](https://swagger.io/specification/v2/) specifications. Built on top of
77
`go-openapi/spec`, it is a central utility in the go-swagger ecosystem for code generation
88
and validation tooling.
@@ -16,6 +16,7 @@ and validation tooling.
1616
| `flatten.go` | `Flatten(FlattenOpts)` — multi-step pipeline: expand, normalize, name inline schemas, strip OAIGen, remove unused |
1717
| `mixin.go` | `Mixin(primary, mixins...)` — merges specs, returns collision warnings |
1818
| `fixer.go` | `FixEmptyResponseDescriptions()` — patches empty response descriptions |
19+
| `diff/` | `Compare(spec1, spec2)` — compares two specs and reports structural and compatibility changes |
1920

2021
Internal packages live under `internal/` (debug, antest, flatten/{normalize,operations,replace,schutils,sortref}).
2122

@@ -24,6 +25,7 @@ Internal packages live under `internal/` (debug, antest, flatten/{normalize,oper
2425
- `New(*spec.Swagger) *Spec` — build an analyzed index from a parsed spec
2526
- `Flatten(FlattenOpts) error` — flatten/expand a spec
2627
- `Mixin(primary, mixins...) []string` — merge multiple specs
28+
- `diff.Compare(spec1, spec2 *spec.Swagger) (SpecDifferences, error)` — compare two specs
2729
- `Schema(SchemaOpts) (*AnalyzedSchema, error)` — classify a schema
2830

2931
### Dependencies

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
---
1414

15-
A foundational library to analyze an OAI specification document for easier reasoning about the content.
15+
A foundational library to analyze, diff, flatten, merge, and fix OAI specification documents for easier reasoning about the content.
1616

1717
## Announcements
1818

@@ -38,6 +38,7 @@ go get github.com/go-openapi/analysis
3838

3939
* An analyzer providing methods to walk the functional content of a specification
4040
* A spec flattener producing a self-contained document bundle, while preserving `$ref`s
41+
* A spec differ ("diff") to compare two specs and report structural and compatibility changes
4142
* A spec merger ("mixin") to merge several spec documents into a primary spec
4243
* A spec "fixer" ensuring that response descriptions are non empty
4344

0 commit comments

Comments
 (0)