Confluence REST JSon Schema
Asked by Sebastian Bicchi:

Hello,

is there a JSON Schema for the Confluence REST API? I haven't found anything.

I would like to generate a Java stub for gson with <http://www.jsonschema2pojo.org> . Yes, I *could* just paste the JSON response into that tool, but the resulting classes do not have nice names. Also I would need to expand literally every field to get a complete POJO Stub. The next thing is, that it seems that the response is different for type=blogpost and type=site. For example the blogpost has a "CreatedBy" Field while the site has only a "By" Field. Therefore I would like to have a schema to generate one generic stub.

BG Sebastian


Answers:
author: Jost Berthold
body: Thanks for the schema, looks very useful. Will use this until official documentation turns up...


author: Sebastian Bicchi
body: Meanwhile I figured out, that the difference is caused by different versions of confluence.

@Jost Berthold : Meanwhile you can use this:

```
{"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"results":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"status":{"type":"string"},"title":{"type":"string"},"space":{"type":"object","properties":{"id":{"type":"integer"},"key":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"_links":{"type":"object","properties":{"webui":{"type":"string"},"self":{"type":"string"}},"required":["webui","self"]},"_expandable":{"type":"object","properties":{"metadata":{"type":"string"},"icon":{"type":"string"},"description":{"type":"string"},"homepage":{"type":"string"}},"required":["metadata","icon","description","homepage"]}},"required":["id","key","name","type","_links","_expandable"]},"history":{"type":"object","properties":{"latest":{"type":"boolean"},"createdBy":{"type":"object","properties":{"type":{"type":"string"},"username":{"type":"string"},"userKey":{"type":"string"},"profilePicture":{"type":"object","properties":{"path":{"type":"string"},"width":{"type":"integer"},"height":{"type":"integer"},"isDefault":{"type":"boolean"}},"required":["path","width","height","isDefault"]},"displayName":{"type":"string"},"_links":{"type":"object","properties":{"self":{"type":"string"}},"required":["self"]}},"required":["type","username","userKey","profilePicture","displayName","_links"]},"createdDate":{"type":"string"},"_links":{"type":"object","properties":{"self":{"type":"string"}},"required":["self"]},"_expandable":{"type":"object","properties":{"lastUpdated":{"type":"string"},"previousVersion":{"type":"string"},"contributors":{"type":"string"},"nextVersion":{"type":"string"}},"required":["lastUpdated","previousVersion","contributors","nextVersion"]}},"required":["latest","createdBy","createdDate","_links","_expandable"]},"body":{"type":"object","properties":{"view":{"type":"object","properties":{"value":{"type":"string"},"representation":{"type":"string"},"_expandable":{"type":"object","properties":{"webresource":{"type":"string"},"content":{"type":"string"}},"required":["webresource","content"]}},"required":["value","representation","_expandable"]},"export_view":{"type":"object","properties":{"value":{"type":"string"},"representation":{"type":"string"},"_expandable":{"type":"object","properties":{"webresource":{"type":"string"},"content":{"type":"string"}},"required":["webresource","content"]}},"required":["value","representation","_expandable"]},"_expandable":{"type":"object","properties":{"editor":{"type":"string"},"styled_view":{"type":"string"},"storage":{"type":"string"},"anonymous_export_view":{"type":"string"}},"required":["editor","styled_view","storage","anonymous_export_view"]}},"required":["view","export_view","_expandable"]},"metadata":{"type":"object","properties":{"labels":{"type":"object","properties":{"results":{"type":"array","items":{}},"start":{"type":"integer"},"limit":{"type":"integer"},"size":{"type":"integer"},"_links":{"type":"object","properties":{"self":{"type":"string"}},"required":["self"]}},"required":["results","start","limit","size","_links"]},"_expandable":{"type":"object","properties":{"currentuser":{"type":"string"},"properties":{"type":"string"}},"required":["currentuser","properties"]}},"required":["labels","_expandable"]},"_links":{"type":"object","properties":{"webui":{"type":"string"},"tinyui":{"type":"string"},"self":{"type":"string"}},"required":["webui","tinyui","self"]},"_expandable":{"type":"object","properties":{"container":{"type":"string"},"operations":{"type":"string"},"children":{"type":"string"},"ancestors":{"type":"string"},"version":{"type":"string"},"descendants":{"type":"string"}},"required":["container","operations","children","ancestors","version","descendants"]}},"required":["id","type","status","title","space","history","body","metadata","_links","_expandable"]}},"start":{"type":"integer"},"limit":{"type":"integer"},"size":{"type":"integer"},"_links":{"type":"object","properties":{"self":{"type":"string"},"base":{"type":"string"},"context":{"type":"string"}},"required":["self","base","context"]}},"required":["results","start","limit","size","_links"]}
```

Not sure if everything is fine. Use your query against your confluence instance and put it in this tool: <http://jsonschema.net/#/>


author: Jost Berthold
body: ...looking for the same thing, precise specification of the JSON used in requests and responses in the Confluence REST API.

In my case, it is for specifying the API in Haskell (Servant), which requires defining all JSON content as data types (I certainly don't want to just use a free-form name-value dictionary... :smile: ).