Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.

Commit 17ba42e

Browse files
Rename Swagger references to OpenAPI (oapi-codegen#2202)
Co-authored-by: Marcin Romaszewicz <mromaszewicz@nvidia.com>
1 parent db8abb8 commit 17ba42e

25 files changed

Lines changed: 264 additions & 264 deletions

File tree

experimental/examples/callback/treefarm.gen.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

experimental/examples/petstore-expanded/petstore.gen.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

experimental/examples/webhook/doorbadge.gen.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

experimental/internal/codegen/inline.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
// generateEmbeddedSpec produces Go code that embeds the raw OpenAPI spec as
12-
// gzip+base64 encoded data, with a public GetSwaggerSpecJSON() function to
12+
// gzip+base64 encoded data, with a public GetOpenAPISpecJSON() function to
1313
// retrieve the decompressed JSON bytes.
1414
func generateEmbeddedSpec(specData []byte) (string, error) {
1515
// Gzip compress
@@ -43,15 +43,15 @@ func generateEmbeddedSpec(specData []byte) (string, error) {
4343
var b strings.Builder
4444

4545
b.WriteString("// Base64-encoded, gzip-compressed OpenAPI spec.\n")
46-
b.WriteString("var swaggerSpecJSON = []string{\n")
46+
b.WriteString("var openAPISpecJSON = []string{\n")
4747
for _, chunk := range chunks {
4848
fmt.Fprintf(&b, "\t%q,\n", chunk)
4949
}
5050
b.WriteString("}\n\n")
5151

52-
b.WriteString("// decodeSwaggerSpec decodes and decompresses the embedded spec.\n")
53-
b.WriteString("func decodeSwaggerSpec() ([]byte, error) {\n")
54-
b.WriteString("\tjoined := strings.Join(swaggerSpecJSON, \"\")\n")
52+
b.WriteString("// decodeOpenAPISpec decodes and decompresses the embedded spec.\n")
53+
b.WriteString("func decodeOpenAPISpec() ([]byte, error) {\n")
54+
b.WriteString("\tjoined := strings.Join(openAPISpecJSON, \"\")\n")
5555
b.WriteString("\traw, err := base64.StdEncoding.DecodeString(joined)\n")
5656
b.WriteString("\tif err != nil {\n")
5757
b.WriteString("\t\treturn nil, fmt.Errorf(\"decoding base64: %w\", err)\n")
@@ -68,24 +68,24 @@ func generateEmbeddedSpec(specData []byte) (string, error) {
6868
b.WriteString("\treturn out.Bytes(), nil\n")
6969
b.WriteString("}\n\n")
7070

71-
b.WriteString("// decodeSwaggerSpecCached returns a closure that caches the decoded spec.\n")
72-
b.WriteString("func decodeSwaggerSpecCached() func() ([]byte, error) {\n")
71+
b.WriteString("// decodeOpenAPISpecCached returns a closure that caches the decoded spec.\n")
72+
b.WriteString("func decodeOpenAPISpecCached() func() ([]byte, error) {\n")
7373
b.WriteString("\tvar cached []byte\n")
7474
b.WriteString("\tvar cachedErr error\n")
7575
b.WriteString("\tvar once sync.Once\n")
7676
b.WriteString("\treturn func() ([]byte, error) {\n")
7777
b.WriteString("\t\tonce.Do(func() {\n")
78-
b.WriteString("\t\t\tcached, cachedErr = decodeSwaggerSpec()\n")
78+
b.WriteString("\t\t\tcached, cachedErr = decodeOpenAPISpec()\n")
7979
b.WriteString("\t\t})\n")
8080
b.WriteString("\t\treturn cached, cachedErr\n")
8181
b.WriteString("\t}\n")
8282
b.WriteString("}\n\n")
8383

84-
b.WriteString("var swaggerSpec = decodeSwaggerSpecCached()\n\n")
84+
b.WriteString("var openAPISpec = decodeOpenAPISpecCached()\n\n")
8585

86-
b.WriteString("// GetSwaggerSpecJSON returns the raw OpenAPI spec as JSON bytes.\n")
87-
b.WriteString("func GetSwaggerSpecJSON() ([]byte, error) {\n")
88-
b.WriteString("\treturn swaggerSpec()\n")
86+
b.WriteString("// GetOpenAPISpecJSON returns the raw OpenAPI spec as JSON bytes.\n")
87+
b.WriteString("func GetOpenAPISpecJSON() ([]byte, error) {\n")
88+
b.WriteString("\treturn openAPISpec()\n")
8989
b.WriteString("}\n")
9090

9191
return b.String(), nil

experimental/internal/codegen/inline_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ func TestGenerateEmbeddedSpec(t *testing.T) {
1919
require.NoError(t, err)
2020

2121
// Should contain the chunked base64 variable
22-
assert.Contains(t, code, "var swaggerSpecJSON = []string{")
22+
assert.Contains(t, code, "var openAPISpecJSON = []string{")
2323

2424
// Should contain the decode function
25-
assert.Contains(t, code, "func decodeSwaggerSpec() ([]byte, error)")
25+
assert.Contains(t, code, "func decodeOpenAPISpec() ([]byte, error)")
2626

2727
// Should contain the cached decode function
28-
assert.Contains(t, code, "func decodeSwaggerSpecCached() func() ([]byte, error)")
28+
assert.Contains(t, code, "func decodeOpenAPISpecCached() func() ([]byte, error)")
2929

3030
// Should contain the public API
31-
assert.Contains(t, code, "func GetSwaggerSpecJSON() ([]byte, error)")
31+
assert.Contains(t, code, "func GetOpenAPISpecJSON() ([]byte, error)")
3232

3333
// Should contain the cached var
34-
assert.Contains(t, code, "var swaggerSpec = decodeSwaggerSpecCached()")
34+
assert.Contains(t, code, "var openAPISpec = decodeOpenAPISpecCached()")
3535
}
3636

3737
func TestGenerateEmbeddedSpecRoundTrip(t *testing.T) {
@@ -101,8 +101,8 @@ components:
101101
assert.Contains(t, code, "type Pet struct")
102102

103103
// Should contain the embedded spec
104-
assert.Contains(t, code, "GetSwaggerSpecJSON")
105-
assert.Contains(t, code, "swaggerSpecJSON")
104+
assert.Contains(t, code, "GetOpenAPISpecJSON")
105+
assert.Contains(t, code, "openAPISpecJSON")
106106
}
107107

108108
func TestGenerateWithNilSpecData(t *testing.T) {
@@ -134,6 +134,6 @@ components:
134134
assert.Contains(t, code, "type Pet struct")
135135

136136
// Should NOT contain the embedded spec
137-
assert.NotContains(t, code, "GetSwaggerSpecJSON")
138-
assert.NotContains(t, code, "swaggerSpecJSON")
137+
assert.NotContains(t, code, "GetOpenAPISpecJSON")
138+
assert.NotContains(t, code, "openAPISpecJSON")
139139
}

experimental/internal/codegen/templates/files/client/base.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Client struct {
1414
// The endpoint of the server conforming to this interface, with scheme,
1515
// https://api.deepmap.com for example. This can contain a path relative
1616
// to the server, such as https://api.deepmap.com/dev-test, and all the
17-
// paths in the swagger spec will be appended to the server.
17+
// paths in the OpenAPI spec will be appended to the server.
1818
Server string
1919

2020
// Doer for performing requests, typically a *http.Client with any

experimental/internal/codegen/test/comprehensive/output/comprehensive.gen.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

experimental/internal/codegen/test/issues/issue_1029/output/types.gen.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)