Object structure from api response

I want to extract somehow object structure from this API so i can display it in my atlassian connect app
Confluence Rest API
But neither in OpenAPI nor Postman Collection json file , there is no way to retrieve this object structure

So my question is , wheter its possible to get this object structure in code , and not manually copy/paste it

Can you explain this assertion more? I don’t know if I understand why you can’t.

Using the Confluence v2 Open API spec, I searched for the path you hyperlinked: /spaces/{id} and I found this substructure:

  "/spaces/{id}": {
    "get": {
      "tags": ["Space"],
      "operationId": "getSpaceById",
      "summary": "Get space by id",
      "description": "Returns a specific space.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nPermission to view the space.",
      "parameters": [],
      "responses": {
        "200": {
          "description": "Returned if the requested space is returned.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Space"
              }
            }
          }
        },
        "400": {},
        "401": {},
        "404": {}
      },
      "security": []
    }
  }

That tells us the schema for this response is defined in #/components/schemas/Space, or, as a JavaScript style object path components.schemas.Space, which gives me:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "ID of the space."
    },
    "key": {
      "type": "string",
      "description": "Key of the space."
    },
    "name": {
      "type": "string",
      "description": "Name of the space."
    },
    "type": {
      "$ref": "#/components/schemas/SpaceType"
    },
    "status": {
      "$ref": "#/components/schemas/SpaceStatus"
    },
    "authorId": {
      "type": "string",
      "description": "The account ID of the user who created this space originally."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "Date and time when the space was created. In format \"YYYY-MM-DDTHH:mm:ss.sssZ\"."
    },
    "homepageId": {
      "type": "string",
      "description": "ID of the space's homepage."
    },
    "description": {
      "$ref": "#/components/schemas/SpaceDescription"
    },
    "icon": {
      "$ref": "#/components/schemas/SpaceIcon"
    },
    "_links": {
      "$ref": "#/components/schemas/SpaceLinks"
    }
  }
}

As we can see, this has further type references, which need to be dereferenced & assembled into a “type”. The structure is there. It should be navigable via standard Open API libraries because that’s how our doc generator constructs the example that you’ve screenshot. I couldn’t make more specific recommendations without knowing what language you are working with.

That said, I do understand if the programmatic approach is simply more work than “manually copy/paste it”. If you only need an example of the JSON structure for 1 endpoint, and not the full comprehension of the entire API’s schema, then why not copy/paste?

1 Like

Thank you, it seems to be a valid solution, but i dont use JavaScript, however as i understand there should url where this will be available, something like
https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-space/components/schemas/Space
, but this particular url does not work

@AdriianSemotiuk,

It’s not a URL. It’s a “path” inside the Open API spec.

1 Like