## Background

Check the validity of a configuration against its entity schema. This
allows you to test your input before submitting a request to the
entity endpoints of the Admin API.

Note that this only performs the schema validation checks, checking
that the input configuration is well-formed. Requests to the entity
endpoint using the given configuration may still fail due to other
reasons, such as invalid foreign key relationships or uniqueness check
failures against the contents of the data store.

## Admin API definition

POST /apisix/admin/schema/validate/{resource}

* 200: validate ok.
* 400: validate failed, with error as response body in JSON format.

Example:

```bash
curl http://127.0.0.1:9180/apisix/admin/schema/validate/routes \
    -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -i -d '{
    "uri": 1980,
    "upstream": {
        "scheme": "https",
        "type": "roundrobin",
        "nodes": {
            "nghttp2.org": 1
        }
    }
}'
HTTP/1.1 400 Bad Request
Date: Mon, 21 Aug 2023 07:37:13 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Server: APISIX/3.4.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 3600

{"error_msg":"property \"uri\" validation failed: wrong type: expected
string, got number"}
```

Reply via email to