# Are there some JSON Schema files for Node-RED HTTP APIs?

**URL:** <https://discourse.nodered.org/t/are-there-some-json-schema-files-for-node-red-http-apis/63840>\
**Category:** General\
**Created:** [13 June 2022 06:49 UTC](https://discourse.nodered.org/t/are-there-some-json-schema-files-for-node-red-http-apis/63840 "2022-06-13T06:49:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [13 June 2022 06:49 UTC](https://discourse.nodered.org/t/are-there-some-json-schema-files-for-node-red-http-apis/63840/1 "2022-06-13T06:49:32Z")

</div>

I was looking to creating some API Integration Tests and generally a good idea would be to use JSON Schema for the Requests/Requests responses? One can use these schema files to check conformity.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 June 2022 07:09 UTC](https://discourse.nodered.org/t/are-there-some-json-schema-files-for-node-red-http-apis/63840/2 "2022-06-13T07:09:51Z")

</div>

Did you search flows library?

[https://flows.nodered.org/search?term=schema](https://flows.nodered.org/search?term=schema)

Also, in case you were not aware - the built in JSON node accepts a schema...

RTM...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd04fdbf2b0cbfebe241a6d90c2a07206bc90659.png)

---

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [13 June 2022 07:49 UTC](https://discourse.nodered.org/t/are-there-some-json-schema-files-for-node-red-http-apis/63840/3 "2022-06-13T07:49:14Z")

</div>

Not for flows, but I meant the HTTP Admin APIs [Authentication : Node-RED](https://nodered.org/docs/api/admin/oauth) I was trying to work out some simple HTTP API integration tests when creating a custom Node-RED docker container. The Schema for the response of the HTTP Admin APIs was what I can use to validate if the container is running accordingly.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 June 2022 07:55 UTC](https://discourse.nodered.org/t/are-there-some-json-schema-files-for-node-red-http-apis/63840/4 "2022-06-13T07:55:49Z")

</div>

Would be nice if you include that info up front!

> [@Shan](#):
>
> I was trying to work out some simple HTTP API integration tests when creating a custom Node-RED docker container

Then just import a JSON validation library and do what is necessary.

> [@Shan](#):
>
> I was trying to work out some simple HTTP API integration tests

a [duck type test](https://stackoverflow.com/questions/4205130/what-is-duck-typing) is more "simple"

---

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [13 June 2022 11:23 UTC](https://discourse.nodered.org/t/are-there-some-json-schema-files-for-node-red-http-apis/63840/5 "2022-06-13T11:23:38Z")

</div>

Apologies for the unclear description, As you mentioned a validator was the way to go.

I have been able to create some JSON Schemas created for the API as reference for the community

## `/auth/login` Response Schema

```json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
        "type": {
            "type": "string"
        },
        "prompts": {
            "type": "array",
            "items": {
                "$ref": "#/$defs/prompt"
            }
        }
    },
    "$defs": {
        "prompt": {
            "type": "object",
            "required": ["id", "type", "label"],
            "properties": {
                "id": {
                    "type": "string"
                },
                "type": {
                    "type": "string"
                },
                "label": {
                    "type": "string"
                }
            }
        }
    }
}

```

## `/nodes` Response Schema

```json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "array",
    "items": {
        "$ref": "#/$defs/node"
    },
    "$defs": {
        "node": {
            "type": "object",
            "required": ["id", "name", "types", "enabled", "module", "version"],
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "types": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "enabled": {
                    "type": "boolean"
                },
                "module": {
                    "type": "string"
                },
                "version": {
                    "type": "string"
                }
            }
        }
    }
}

```

I am still working on `/flows` API and I am not sure which fields should be marked `required` but I will update the schema here.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 June 2022 11:23 UTC](https://discourse.nodered.org/t/are-there-some-json-schema-files-for-node-red-http-apis/63840/6 "2022-06-27T11:23:40Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
