schemas
Creates, updates, deletes, gets or lists a schemas resource.
Overview
| Name | schemas |
| Type | Resource |
| Id | cloudflare.schema_validation.schemas |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
name | string | A human-readable name for the schema (example: petstore schema) |
schema_id | string (uuid) | A unique identifier of this schema (example: f174e90a-fafe-4643-bbbc-4a0ed4fc8415) |
created_at | string (date-time) | (example: 2014-01-01T05:20:00.12345Z) |
kind | string | The kind of the schema (openapi_v3) (example: openapi_v3) |
source | string | The raw schema, e.g., the OpenAPI schema, either as JSON or YAML (example: <schema file contents>) |
validation_enabled | boolean | An indicator if this schema is enabled |
| Name | Datatype | Description |
|---|---|---|
name | string | A human-readable name for the schema (example: petstore schema) |
schema_id | string (uuid) | A unique identifier of this schema (example: f174e90a-fafe-4643-bbbc-4a0ed4fc8415) |
created_at | string (date-time) | (example: 2014-01-01T05:20:00.12345Z) |
kind | string | The kind of the schema (openapi_v3) (example: openapi_v3) |
source | string | The raw schema, e.g., the OpenAPI schema, either as JSON or YAML (example: <schema file contents>) |
validation_enabled | boolean | An indicator if this schema is enabled |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | zone_id, schema_id | omit_source | Gets the contents and metadata of a specific OpenAPI schema uploaded to API Shield. |
list | select | zone_id | page, per_page, omit_source, validation_enabled | Lists all OpenAPI schemas uploaded to API Shield with pagination support. |
create | insert | zone_id, name, kind, source, validation_enabled | Uploads a new OpenAPI schema for API Shield schema validation. The schema defines expected request/response formats for API endpoints. | |
edit | update | zone_id, schema_id | Modifies an existing OpenAPI schema in API Shield, updating the validation rules for associated API operations. | |
delete | delete | zone_id, schema_id | Permanently 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.
| Name | Datatype | Description |
|---|---|---|
schema_id | string (uuid) | The unique identifier of the schema |
zone_id | string | The Cloudflare zone ID. |
omit_source | boolean | Omit the source-files of schemas and only retrieve their meta-data. |
page | integer | Page number of paginated results. |
per_page | integer | Maximum number of results per page. |
validation_enabled | boolean | Filter for enabled schemas |
SELECT examples
- get
- list
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 }}'
;
Lists all OpenAPI schemas uploaded to API Shield with pagination support.
SELECT
name,
schema_id,
created_at,
kind,
source,
validation_enabled
FROM cloudflare.schema_validation.schemas
WHERE zone_id = '{{ zone_id }}' -- required
AND page = '{{ page }}'
AND per_page = '{{ per_page }}'
AND omit_source = '{{ omit_source }}'
AND validation_enabled = '{{ validation_enabled }}'
;
INSERT examples
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: schemas
props:
- name: zone_id
value: "{{ zone_id }}"
description: Required parameter for the schemas resource.
- name: kind
value: "{{ kind }}"
description: |
The kind of the schema
valid_values: ['openapi_v3']
- name: name
value: "{{ name }}"
description: |
A human-readable name for the schema
- name: source
value: "{{ source }}"
description: |
The raw schema, e.g., the OpenAPI schema, either as JSON or YAML
- name: validation_enabled
value: {{ validation_enabled }}
description: |
An indicator if this schema is enabled
UPDATE examples
- edit
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
- delete
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
;