Skip to content

Commit b641244

Browse files
committed
revert to go 1.25 and revert cc4f8d9
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
1 parent ff4bce7 commit b641244

14 files changed

Lines changed: 102 additions & 38 deletions

.github/docs/openapi3.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ var IncludeOrigin = false
121121

122122
FUNCTIONS
123123

124+
func BoolPtr(value bool) *bool
125+
BoolPtr is a helper for defining OpenAPI schemas.
126+
127+
Deprecated: Use Ptr instead.
128+
124129
func DefaultRefNameResolver(doc *T, ref ComponentRef) string
125130
DefaultRefResolver is a default implementation of refNameResolver for the
126131
InternalizeRefs function.
@@ -169,6 +174,19 @@ func DefineStringFormatValidator(name string, validator StringFormatValidator)
169174
DefineStringFormatValidator defines a custom format validator for a given
170175
string format.
171176

177+
func Float64Ptr(value float64) *float64
178+
Float64Ptr is a helper for defining OpenAPI schemas.
179+
180+
Deprecated: Use Ptr instead.
181+
182+
func Int64Ptr(value int64) *int64
183+
Int64Ptr is a helper for defining OpenAPI schemas.
184+
185+
Deprecated: Use Ptr instead.
186+
187+
func Ptr[T any](value T) *T
188+
Ptr is a helper for defining OpenAPI schemas.
189+
172190
func ReadFromFile(loader *Loader, location *url.URL) ([]byte, error)
173191
ReadFromFile is a ReadFromURIFunc which reads local file URIs.
174192

@@ -218,6 +236,11 @@ func RegisterArrayUniqueItemsChecker(fn SliceUniqueItemsChecker)
218236
RegisterArrayUniqueItemsChecker is used to register a customized function
219237
used to check if JSON array have unique items.
220238

239+
func Uint64Ptr(value uint64) *uint64
240+
Uint64Ptr is a helper for defining OpenAPI schemas.
241+
242+
Deprecated: Use Ptr instead.
243+
221244
func ValidateIdentifier(value string) error
222245
ValidateIdentifier returns an error if the given component name does not
223246
match IdentifierRegExp.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ for _, path := range doc.Paths.InMatchingOrder() {
313313

314314
## CHANGELOG: Sub-v1 breaking API changes
315315

316+
### v0.137.0
317+
* Reinstated `openapi3.*Ptr(..)` funcs for Go 1.25
318+
316319
### v0.136.0
317320
* `openapi3.Schema.ExclusiveMin` and `openapi3.Schema.ExclusiveMax` fields changed from `bool` to `ExclusiveBound` (a union type holding `*bool` for OpenAPI 3.0 or `*float64` for OpenAPI 3.1).
318321
* `openapi3.Schema.PrefixItems` field changed from `[]*SchemaRef` to `SchemaRefs`.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/getkin/kin-openapi
22

3-
go 1.26
3+
go 1.25
44

55
require (
66
github.com/go-openapi/jsonpointer v0.21.0

openapi2conv/openapi2_conv.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,11 +1348,12 @@ func compareParameters(a, b *openapi2.Parameter) int {
13481348
return cmp.Compare(a.Ref, b.Ref)
13491349
}
13501350

1351+
// boolPtr returns a pointer to a bool, or nil if the value is false (to avoid storing empty values)
13511352
func boolPtr(b bool) *bool {
1352-
if b {
1353-
return new(b)
1353+
if !b {
1354+
return nil
13541355
}
1355-
return nil
1356+
return &b
13561357
}
13571358

13581359
// exclusiveBoundToBool converts an ExclusiveBound to a bool for OpenAPI 2.0 compatibility

openapi3/encoding_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func encoding() *Encoding {
5151
},
5252
},
5353
Style: "form",
54-
Explode: new(true),
54+
Explode: Ptr(true),
5555
AllowReserved: true,
5656
}
5757
}
@@ -73,17 +73,17 @@ func TestEncodingSerializationMethod(t *testing.T) {
7373
},
7474
{
7575
name: "encoding with explode",
76-
enc: &Encoding{Explode: new(true)},
76+
enc: &Encoding{Explode: Ptr(true)},
7777
want: &SerializationMethod{Style: SerializationForm, Explode: true},
7878
},
7979
{
8080
name: "encoding with no explode",
81-
enc: &Encoding{Explode: new(false)},
81+
enc: &Encoding{Explode: Ptr(false)},
8282
want: &SerializationMethod{Style: SerializationForm, Explode: false},
8383
},
8484
{
8585
name: "encoding with style and explode ",
86-
enc: &Encoding{Style: SerializationSpaceDelimited, Explode: new(false)},
86+
enc: &Encoding{Style: SerializationSpaceDelimited, Explode: Ptr(false)},
8787
want: &SerializationMethod{Style: SerializationSpaceDelimited, Explode: false},
8888
},
8989
}

openapi3/helpers.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,39 @@ func ValidateIdentifier(value string) error {
3131
return fmt.Errorf("identifier %q is not supported by OpenAPIv3 standard (charset: [%q])", value, identifierChars)
3232
}
3333

34+
// Ptr is a helper for defining OpenAPI schemas.
35+
func Ptr[T any](value T) *T {
36+
return &value
37+
}
38+
39+
// Float64Ptr is a helper for defining OpenAPI schemas.
40+
//
41+
// Deprecated: Use Ptr instead.
42+
func Float64Ptr(value float64) *float64 {
43+
return &value
44+
}
45+
46+
// BoolPtr is a helper for defining OpenAPI schemas.
47+
//
48+
// Deprecated: Use Ptr instead.
49+
func BoolPtr(value bool) *bool {
50+
return &value
51+
}
52+
53+
// Int64Ptr is a helper for defining OpenAPI schemas.
54+
//
55+
// Deprecated: Use Ptr instead.
56+
func Int64Ptr(value int64) *int64 {
57+
return &value
58+
}
59+
60+
// Uint64Ptr is a helper for defining OpenAPI schemas.
61+
//
62+
// Deprecated: Use Ptr instead.
63+
func Uint64Ptr(value uint64) *uint64 {
64+
return &value
65+
}
66+
3467
// componentNames returns the map keys in a sorted slice.
3568
func componentNames[E any](s map[string]E) []string {
3669
out := make([]string, 0, len(s))

openapi3/issue230_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ webhooks:
291291
Responses: openapi3.NewResponses(
292292
openapi3.WithStatus(200, &openapi3.ResponseRef{
293293
Value: &openapi3.Response{
294-
Description: new("OK"),
294+
Description: openapi3.Ptr("OK"),
295295
},
296296
}),
297297
),

openapi3/issue376_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ info:
4545
func TestExclusiveValuesOfValuesAdditionalProperties(t *testing.T) {
4646
schema := &Schema{
4747
AdditionalProperties: AdditionalProperties{
48-
Has: new(false),
48+
Has: Ptr(false),
4949
Schema: NewSchemaRef("", &Schema{}),
5050
},
5151
}
@@ -54,7 +54,7 @@ func TestExclusiveValuesOfValuesAdditionalProperties(t *testing.T) {
5454

5555
schema = &Schema{
5656
AdditionalProperties: AdditionalProperties{
57-
Has: new(false),
57+
Has: Ptr(false),
5858
},
5959
}
6060
err = schema.Validate(t.Context())

openapi3/issue735_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestIssue735(t *testing.T) {
7474
},
7575
{
7676
name: "multiple of",
77-
schema: &Schema{MultipleOf: new(5.0)},
77+
schema: &Schema{MultipleOf: Ptr(5.0)},
7878
value: 42,
7979
},
8080
{
@@ -142,7 +142,7 @@ func TestIssue735(t *testing.T) {
142142
{
143143
name: "additional properties false",
144144
schema: &Schema{AdditionalProperties: AdditionalProperties{
145-
Has: new(false),
145+
Has: Ptr(false),
146146
}},
147147
value: map[string]any{"foo": 42},
148148
extraNotContains: []any{42},
@@ -188,40 +188,40 @@ func TestIssue735(t *testing.T) {
188188
{
189189
name: "one of (matches more then one)",
190190
schema: NewOneOfSchema(
191-
&Schema{MultipleOf: new(6.0)},
192-
&Schema{MultipleOf: new(7.0)},
191+
&Schema{MultipleOf: Ptr(6.0)},
192+
&Schema{MultipleOf: Ptr(7.0)},
193193
),
194194
value: 42,
195195
},
196196
{
197197
name: "one of (no matches)",
198198
schema: NewOneOfSchema(
199-
&Schema{MultipleOf: new(5.0)},
200-
&Schema{MultipleOf: new(10.0)},
199+
&Schema{MultipleOf: Ptr(5.0)},
200+
&Schema{MultipleOf: Ptr(10.0)},
201201
),
202202
value: 42,
203203
},
204204
{
205205
name: "any of",
206206
schema: NewAnyOfSchema(
207-
&Schema{MultipleOf: new(5.0)},
208-
&Schema{MultipleOf: new(10.0)},
207+
&Schema{MultipleOf: Ptr(5.0)},
208+
&Schema{MultipleOf: Ptr(10.0)},
209209
),
210210
value: 42,
211211
},
212212
{
213213
name: "all of (match some)",
214214
schema: NewAllOfSchema(
215-
&Schema{MultipleOf: new(6.0)},
216-
&Schema{MultipleOf: new(5.0)},
215+
&Schema{MultipleOf: Ptr(6.0)},
216+
&Schema{MultipleOf: Ptr(5.0)},
217217
),
218218
value: 42,
219219
},
220220
{
221221
name: "all of (no match)",
222222
schema: NewAllOfSchema(
223-
&Schema{MultipleOf: new(10.0)},
224-
&Schema{MultipleOf: new(5.0)},
223+
&Schema{MultipleOf: Ptr(10.0)},
224+
&Schema{MultipleOf: Ptr(5.0)},
225225
),
226226
value: 42,
227227
},

openapi3/openapi3_version_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestWebhooksField(t *testing.T) {
2525
Responses: openapi3.NewResponses(
2626
openapi3.WithStatus(200, &openapi3.ResponseRef{
2727
Value: &openapi3.Response{
28-
Description: new("Success"),
28+
Description: openapi3.Ptr("Success"),
2929
},
3030
}),
3131
),
@@ -107,7 +107,7 @@ func TestWebhooksField(t *testing.T) {
107107
Responses: openapi3.NewResponses(
108108
openapi3.WithStatus(200, &openapi3.ResponseRef{
109109
Value: &openapi3.Response{
110-
Description: new("Success"),
110+
Description: openapi3.Ptr("Success"),
111111
},
112112
}),
113113
),
@@ -199,7 +199,7 @@ func TestVersionBasedBehavior(t *testing.T) {
199199
Responses: openapi3.NewResponses(
200200
openapi3.WithStatus(200, &openapi3.ResponseRef{
201201
Value: &openapi3.Response{
202-
Description: new("OK"),
202+
Description: openapi3.Ptr("OK"),
203203
},
204204
}),
205205
),
@@ -242,7 +242,7 @@ func TestMigrationScenario(t *testing.T) {
242242
Responses: openapi3.NewResponses(
243243
openapi3.WithStatus(200, &openapi3.ResponseRef{
244244
Value: &openapi3.Response{
245-
Description: new("Processed"),
245+
Description: openapi3.Ptr("Processed"),
246246
},
247247
}),
248248
),

0 commit comments

Comments
 (0)