Skip to main content

schemas

Creates, updates, deletes, gets or lists a schemas resource.

Overview

Nameschemas
TypeResource
Idcloudflare.schema_validation.schemas

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringA human-readable name for the schema (example: petstore schema)
schema_idstring (uuid)A unique identifier of this schema (example: f174e90a-fafe-4643-bbbc-4a0ed4fc8415)
created_atstring (date-time) (example: 2014-01-01T05:20:00.12345Z)
kindstringThe kind of the schema (openapi_v3) (example: openapi_v3)
sourcestringThe raw schema, e.g., the OpenAPI schema, either as JSON or YAML (example: <schema file contents>)
validation_enabledbooleanAn indicator if this schema is enabled

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectzone_id, schema_idomit_sourceGets the contents and metadata of a specific OpenAPI schema uploaded to API Shield.
listselectzone_idpage, per_page, omit_source, validation_enabledLists all OpenAPI schemas uploaded to API Shield with pagination support.
createinsertzone_id, name, kind, source, validation_enabledUploads a new OpenAPI schema for API Shield schema validation. The schema defines expected request/response formats for API endpoints.
editupdatezone_id, schema_idModifies an existing OpenAPI schema in API Shield, updating the validation rules for associated API operations.
deletedeletezone_id, schema_idPermanently removes an uploaded OpenAPI schema from API Shield. Operations using this schema will lose their validation rules.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
schema_idstring (uuid)The unique identifier of the schema
zone_idstringThe Cloudflare zone ID.
omit_sourcebooleanOmit the source-files of schemas and only retrieve their meta-data.
pageintegerPage number of paginated results.
per_pageintegerMaximum number of results per page.
validation_enabledbooleanFilter for enabled schemas

SELECT examples

Gets the contents and metadata of a specific OpenAPI schema uploaded to API Shield.

SELECT
name,
schema_id,
created_at,
kind,
source,
validation_enabled
FROM cloudflare.schema_validation.schemas
WHERE zone_id = '{{ zone_id }}' -- required
AND schema_id = '{{ schema_id }}' -- required
AND omit_source = '{{ omit_source }}'
;

INSERT examples

Uploads a new OpenAPI schema for API Shield schema validation. The schema defines expected request/response formats for API endpoints.

INSERT INTO cloudflare.schema_validation.schemas (
kind,
name,
source,
validation_enabled,
zone_id
)
SELECT
'{{ kind }}' /* required */,
'{{ name }}' /* required */,
'{{ source }}' /* required */,
{{ validation_enabled }} /* required */,
'{{ zone_id }}'
RETURNING
errors,
messages,
result,
success
;

UPDATE examples

Modifies an existing OpenAPI schema in API Shield, updating the validation rules for associated API operations.

UPDATE cloudflare.schema_validation.schemas
SET
validation_enabled = {{ validation_enabled }}
WHERE
zone_id = '{{ zone_id }}' --required
AND schema_id = '{{ schema_id }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Permanently removes an uploaded OpenAPI schema from API Shield. Operations using this schema will lose their validation rules.

DELETE FROM cloudflare.schema_validation.schemas
WHERE zone_id = '{{ zone_id }}' --required
AND schema_id = '{{ schema_id }}' --required
;