Skip to content

Commit e13a4b0

Browse files
feat: fix: Correctly reflect schema validation model <-> openapi mapping
* fix: Correctly reflect schema validation model <-> openapi mapping Schema validation model is out of sync with openapi definition.
1 parent f733821 commit e13a4b0

File tree

4 files changed

+69
-69
lines changed

4 files changed

+69
-69
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1894
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-367ee4501dc69f2f84249ffcadeef034a8c80b6ce9e6bb701a4d6a59ba2d0f47.yml
33
openapi_spec_hash: bf59e2dded00847fc6ee6b397e8ce120
4-
config_hash: 7730d800f07886a88bc399a5c73a6741
4+
config_hash: c7b8d81b439ef7ee4d865bfc67f8f600

api.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,17 +2802,16 @@ Methods:
28022802
Response Types:
28032803

28042804
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#Message">Message</a>
2805-
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#PublicSchema">PublicSchema</a>
28062805
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#SchemaUpload">SchemaUpload</a>
28072806
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaDeleteResponse">UserSchemaDeleteResponse</a>
28082807

28092808
Methods:
28102809

28112810
- <code title="post /zones/{zone_id}/api_gateway/user_schemas">client.APIGateway.UserSchemas.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaNewParams">UserSchemaNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#SchemaUpload">SchemaUpload</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2812-
- <code title="get /zones/{zone_id}/api_gateway/user_schemas">client.APIGateway.UserSchemas.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaListParams">UserSchemaListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/packages/pagination#V4PagePaginationArray">V4PagePaginationArray</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#PublicSchema">PublicSchema</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2811+
- <code title="get /zones/{zone_id}/api_gateway/user_schemas">client.APIGateway.UserSchemas.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaListParams">UserSchemaListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/packages/pagination#V4PagePaginationArray">V4PagePaginationArray</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation">schema_validation</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation#PublicSchema">PublicSchema</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
28132812
- <code title="delete /zones/{zone_id}/api_gateway/user_schemas/{schema_id}">client.APIGateway.UserSchemas.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, schemaID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaDeleteParams">UserSchemaDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaDeleteResponse">UserSchemaDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2814-
- <code title="patch /zones/{zone_id}/api_gateway/user_schemas/{schema_id}">client.APIGateway.UserSchemas.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaService.Edit">Edit</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, schemaID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaEditParams">UserSchemaEditParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#PublicSchema">PublicSchema</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2815-
- <code title="get /zones/{zone_id}/api_gateway/user_schemas/{schema_id}">client.APIGateway.UserSchemas.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, schemaID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaGetParams">UserSchemaGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#PublicSchema">PublicSchema</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2813+
- <code title="patch /zones/{zone_id}/api_gateway/user_schemas/{schema_id}">client.APIGateway.UserSchemas.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaService.Edit">Edit</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, schemaID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaEditParams">UserSchemaEditParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation">schema_validation</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation#PublicSchema">PublicSchema</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2814+
- <code title="get /zones/{zone_id}/api_gateway/user_schemas/{schema_id}">client.APIGateway.UserSchemas.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, schemaID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/api_gateway#UserSchemaGetParams">UserSchemaGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation">schema_validation</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation#PublicSchema">PublicSchema</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
28162815

28172816
### Operations
28182817

@@ -9457,6 +9456,7 @@ Methods:
94579456

94589457
Response Types:
94599458

9459+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation">schema_validation</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation#PublicSchema">PublicSchema</a>
94609460
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation">schema_validation</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation#SchemaNewResponse">SchemaNewResponse</a>
94619461
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation">schema_validation</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation#SchemaListResponse">SchemaListResponse</a>
94629462
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation">schema_validation</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/schema_validation#SchemaDeleteResponse">SchemaDeleteResponse</a>

api_gateway/userschema.go

Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"net/http"
1313
"net/url"
1414
"slices"
15-
"time"
1615

1716
"github.com/cloudflare/cloudflare-go/v6/internal/apiform"
1817
"github.com/cloudflare/cloudflare-go/v6/internal/apijson"
@@ -21,6 +20,7 @@ import (
2120
"github.com/cloudflare/cloudflare-go/v6/internal/requestconfig"
2221
"github.com/cloudflare/cloudflare-go/v6/option"
2322
"github.com/cloudflare/cloudflare-go/v6/packages/pagination"
23+
"github.com/cloudflare/cloudflare-go/v6/schema_validation"
2424
)
2525

2626
// UserSchemaService contains methods and other services that help with interacting
@@ -72,7 +72,7 @@ func (r *UserSchemaService) New(ctx context.Context, params UserSchemaNewParams,
7272
// Deprecated: Use
7373
// [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/)
7474
// instead.
75-
func (r *UserSchemaService) List(ctx context.Context, params UserSchemaListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[PublicSchema], err error) {
75+
func (r *UserSchemaService) List(ctx context.Context, params UserSchemaListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[schema_validation.PublicSchema], err error) {
7676
var raw *http.Response
7777
opts = slices.Concat(r.Options, opts)
7878
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
@@ -98,7 +98,7 @@ func (r *UserSchemaService) List(ctx context.Context, params UserSchemaListParam
9898
// Deprecated: Use
9999
// [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/)
100100
// instead.
101-
func (r *UserSchemaService) ListAutoPaging(ctx context.Context, params UserSchemaListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[PublicSchema] {
101+
func (r *UserSchemaService) ListAutoPaging(ctx context.Context, params UserSchemaListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[schema_validation.PublicSchema] {
102102
return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...))
103103
}
104104

@@ -127,7 +127,7 @@ func (r *UserSchemaService) Delete(ctx context.Context, schemaID string, body Us
127127
// Deprecated: Use
128128
// [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/)
129129
// instead.
130-
func (r *UserSchemaService) Edit(ctx context.Context, schemaID string, params UserSchemaEditParams, opts ...option.RequestOption) (res *PublicSchema, err error) {
130+
func (r *UserSchemaService) Edit(ctx context.Context, schemaID string, params UserSchemaEditParams, opts ...option.RequestOption) (res *schema_validation.PublicSchema, err error) {
131131
var env UserSchemaEditResponseEnvelope
132132
opts = slices.Concat(r.Options, opts)
133133
if params.ZoneID.Value == "" {
@@ -152,7 +152,7 @@ func (r *UserSchemaService) Edit(ctx context.Context, schemaID string, params Us
152152
// Deprecated: Use
153153
// [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/)
154154
// instead.
155-
func (r *UserSchemaService) Get(ctx context.Context, schemaID string, params UserSchemaGetParams, opts ...option.RequestOption) (res *PublicSchema, err error) {
155+
func (r *UserSchemaService) Get(ctx context.Context, schemaID string, params UserSchemaGetParams, opts ...option.RequestOption) (res *schema_validation.PublicSchema, err error) {
156156
var env UserSchemaGetResponseEnvelope
157157
opts = slices.Concat(r.Options, opts)
158158
if params.ZoneID.Value == "" {
@@ -221,60 +221,10 @@ func (r messageItemSourceJSON) RawJSON() string {
221221
return r.raw
222222
}
223223

224-
type PublicSchema struct {
225-
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
226-
// Kind of schema
227-
Kind PublicSchemaKind `json:"kind,required"`
228-
// Name of the schema
229-
Name string `json:"name,required"`
230-
// UUID.
231-
SchemaID string `json:"schema_id,required"`
232-
// Source of the schema
233-
Source string `json:"source"`
234-
// Flag whether schema is enabled for validation.
235-
ValidationEnabled bool `json:"validation_enabled"`
236-
JSON publicSchemaJSON `json:"-"`
237-
}
238-
239-
// publicSchemaJSON contains the JSON metadata for the struct [PublicSchema]
240-
type publicSchemaJSON struct {
241-
CreatedAt apijson.Field
242-
Kind apijson.Field
243-
Name apijson.Field
244-
SchemaID apijson.Field
245-
Source apijson.Field
246-
ValidationEnabled apijson.Field
247-
raw string
248-
ExtraFields map[string]apijson.Field
249-
}
250-
251-
func (r *PublicSchema) UnmarshalJSON(data []byte) (err error) {
252-
return apijson.UnmarshalRoot(data, r)
253-
}
254-
255-
func (r publicSchemaJSON) RawJSON() string {
256-
return r.raw
257-
}
258-
259-
// Kind of schema
260-
type PublicSchemaKind string
261-
262-
const (
263-
PublicSchemaKindOpenAPIV3 PublicSchemaKind = "openapi_v3"
264-
)
265-
266-
func (r PublicSchemaKind) IsKnown() bool {
267-
switch r {
268-
case PublicSchemaKindOpenAPIV3:
269-
return true
270-
}
271-
return false
272-
}
273-
274224
type SchemaUpload struct {
275-
Schema PublicSchema `json:"schema,required"`
276-
UploadDetails SchemaUploadUploadDetails `json:"upload_details"`
277-
JSON schemaUploadJSON `json:"-"`
225+
Schema schema_validation.PublicSchema `json:"schema,required"`
226+
UploadDetails SchemaUploadUploadDetails `json:"upload_details"`
227+
JSON schemaUploadJSON `json:"-"`
278228
}
279229

280230
// schemaUploadJSON contains the JSON metadata for the struct [SchemaUpload]
@@ -542,9 +492,9 @@ func (r UserSchemaEditParamsValidationEnabled) IsKnown() bool {
542492
}
543493

544494
type UserSchemaEditResponseEnvelope struct {
545-
Errors Message `json:"errors,required"`
546-
Messages Message `json:"messages,required"`
547-
Result PublicSchema `json:"result,required"`
495+
Errors Message `json:"errors,required"`
496+
Messages Message `json:"messages,required"`
497+
Result schema_validation.PublicSchema `json:"result,required"`
548498
// Whether the API call was successful.
549499
Success UserSchemaEditResponseEnvelopeSuccess `json:"success,required"`
550500
JSON userSchemaEditResponseEnvelopeJSON `json:"-"`
@@ -600,9 +550,9 @@ func (r UserSchemaGetParams) URLQuery() (v url.Values) {
600550
}
601551

602552
type UserSchemaGetResponseEnvelope struct {
603-
Errors Message `json:"errors,required"`
604-
Messages Message `json:"messages,required"`
605-
Result PublicSchema `json:"result,required"`
553+
Errors Message `json:"errors,required"`
554+
Messages Message `json:"messages,required"`
555+
Result schema_validation.PublicSchema `json:"result,required"`
606556
// Whether the API call was successful.
607557
Success UserSchemaGetResponseEnvelopeSuccess `json:"success,required"`
608558
JSON userSchemaGetResponseEnvelopeJSON `json:"-"`

schema_validation/schema.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,56 @@ func (r *SchemaService) Get(ctx context.Context, schemaID string, params SchemaG
146146
return
147147
}
148148

149+
type PublicSchema struct {
150+
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
151+
// Kind of schema
152+
Kind PublicSchemaKind `json:"kind,required"`
153+
// Name of the schema
154+
Name string `json:"name,required"`
155+
// UUID.
156+
SchemaID string `json:"schema_id,required"`
157+
// Source of the schema
158+
Source string `json:"source"`
159+
// Flag whether schema is enabled for validation.
160+
ValidationEnabled bool `json:"validation_enabled"`
161+
JSON publicSchemaJSON `json:"-"`
162+
}
163+
164+
// publicSchemaJSON contains the JSON metadata for the struct [PublicSchema]
165+
type publicSchemaJSON struct {
166+
CreatedAt apijson.Field
167+
Kind apijson.Field
168+
Name apijson.Field
169+
SchemaID apijson.Field
170+
Source apijson.Field
171+
ValidationEnabled apijson.Field
172+
raw string
173+
ExtraFields map[string]apijson.Field
174+
}
175+
176+
func (r *PublicSchema) UnmarshalJSON(data []byte) (err error) {
177+
return apijson.UnmarshalRoot(data, r)
178+
}
179+
180+
func (r publicSchemaJSON) RawJSON() string {
181+
return r.raw
182+
}
183+
184+
// Kind of schema
185+
type PublicSchemaKind string
186+
187+
const (
188+
PublicSchemaKindOpenAPIV3 PublicSchemaKind = "openapi_v3"
189+
)
190+
191+
func (r PublicSchemaKind) IsKnown() bool {
192+
switch r {
193+
case PublicSchemaKindOpenAPIV3:
194+
return true
195+
}
196+
return false
197+
}
198+
149199
// A schema used in schema validation
150200
type SchemaNewResponse struct {
151201
CreatedAt time.Time `json:"created_at,required" format:"date-time"`

0 commit comments

Comments
 (0)