Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 139 additions & 3 deletions openapi/components/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,154 @@ Export:
- yaml
Version:
name: version
description: >-
Retrieve an item's state from a specific Content Version. The value corresponds to the "key" of the Content Version.
description: Retrieve an item's state from a specific Content Version. The value corresponds to the "key" of the Content Version.
in: query
required: false
schema:
type: string
Backlink:
name: backlink
description: >-
Retrieve relational items excluding reverse relations when using wildcard fields.
name: backlink
in: query
required: false
schema:
type: boolean
default: true
Aggregate:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While supported I wonder if we should document aggregate querying? In a singleton context it does not make much sense

description: >-
Aggregate functions allow you to perform calculations on a set of values. Accepts one or more of `count`, `countDistinct`, `countAll`, `sum`, `sumDistinct`, `avg`, `avgDistinct`, `min`, `max`.
name: aggregate
in: query
required: false
content:
application/json:
schema:
type: object
properties:
count:
type: array
items:
type: string
description: Count the number of items. Use `['*']` to count all items.
countDistinct:
type: array
items:
type: string
description: Count the number of unique values in the specified fields.
countAll:
type: array
items:
type: string
description: Count all items including related items (used with groupBy).
sum:
type: array
items:
type: string
description: Sum the values of the specified fields.
sumDistinct:
type: array
items:
type: string
description: Sum the unique values of the specified fields.
avg:
type: array
items:
type: string
description: Calculate the average of the specified fields.
avgDistinct:
type: array
items:
type: string
description: Calculate the average of unique values in the specified fields.
min:
type: array
items:
type: string
description: Find the minimum value of the specified fields.
max:
type: array
items:
type: string
description: Find the maximum value of the specified fields.
example:
count: ['*']
sum: ['price']
avg: ['rating']
Deep:
description: Deep allows you to set any of the other query parameters on a nested relational dataset. Use underscore-prefixed parameter names.
name: deep
in: query
required: false
content:
application/json:
schema:
type: object
additionalProperties:
type: object
description: Query parameters for the related field (prefixed with underscore).
properties:
_fields:
type: array
items:
type: string
_sort:
type: array
items:
type: string
_filter:
type: object
_limit:
type: integer
_offset:
type: integer
_page:
type: integer
_search:
type: string
_group:
type: array
items:
type: string
_aggregate:
type: object
example:
related_articles:
_limit: 3
_sort: ['-date_created']
_filter:
status:
_eq: 'published'
Alias:
description: Alias allows you to rename fields in the response payload. The key is the new name, the value is the original field name.
name: alias
in: query
required: false
content:
application/json:
schema:
type: object
additionalProperties:
type: string
example:
display_name: full_name
creation_date: date_created
Group:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as https://github.com/directus/openapi/pull/43/files#r2586004571, in a singleton context group does not make much sense

description: >-
Grouping allows for running the aggregation functions based on a shared value. Accepts an array of field names.
name: group
in: query
required: false
explode: false
schema:
type: array
items:
type: string
VersionRaw:
description: Retrieve the raw delta of a Content Version item instead of the full merged item.
name: versionRaw
in: query
required: false
schema:
type: boolean
default: false
2 changes: 0 additions & 2 deletions openapi/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ paths:
$ref: paths/items/_collection/index.yaml
"/items/{collection}‎":
$ref: paths/items/_collection/singular/index.yaml
"/items/{collection}/singleton":
$ref: paths/items/_collection/singleton/index.yaml
"/items/{collection}/{id}":
$ref: paths/items/_collection/_id/index.yaml
"/metrics":
Expand Down
28 changes: 22 additions & 6 deletions openapi/paths/items/_collection/getCollectionItems.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
summary: List all items in a collection
description: Returns a list of the items in the given collection.
summary: Retrieve items in a collection
description: List all items in a collection or retrieve the plain singleton item.
operationId: getCollectionItems
parameters:
- description: Unique identifier of the collection the item resides in.
Expand All @@ -11,11 +11,19 @@ parameters:
- $ref: ../../../components/parameters.yaml#/Fields
- $ref: ../../../components/parameters.yaml#/Limit
- $ref: ../../../components/parameters.yaml#/Offset
- $ref: ../../../components/parameters.yaml#/Page
- $ref: ../../../components/parameters.yaml#/Meta
- $ref: ../../../components/parameters.yaml#/Sort
- $ref: ../../../components/parameters.yaml#/Filter
- $ref: ../../../components/parameters.yaml#/Search
- $ref: ../../../components/parameters.yaml#/Export
- $ref: ../../../components/parameters.yaml#/Version
- $ref: ../../../components/parameters.yaml#/VersionRaw
- $ref: ../../../components/parameters.yaml#/Backlink
- $ref: ../../../components/parameters.yaml#/Aggregate
- $ref: ../../../components/parameters.yaml#/Group
- $ref: ../../../components/parameters.yaml#/Deep
- $ref: ../../../components/parameters.yaml#/Alias
responses:
'200':
description: Successful request
Expand All @@ -25,9 +33,11 @@ responses:
type: object
properties:
data:
type: array
items:
$ref: ../../../components/schemas/items.yaml
oneOf:
- type: array
items:
$ref: ../../../components/schemas/items.yaml
- $ref: ../../../components/schemas/items.yaml
'401':
$ref: ../../../components/responses.yaml#/UnauthorizedError
'404':
Expand All @@ -39,14 +49,20 @@ x-codeSamples:
- label: Directus SDK
lang: JavaScript
source: |
import { createDirectus, rest, readItems } from '@directus/sdk';
import { createDirectus, rest, readItems, readSingleton } from '@directus/sdk';

const client = createDirectus('directus_project_url').with(rest());

const result = await client.request(readItems('collection_name', query_object));

const singleton = await client.request(readSingleton('collection_name'));
- label: GraphQL
lang: GraphQL
source: |
type Query {
# For regular collections (returns array)
<collection>: [<collection>]

# For singleton collections (returns single object)
<collection>(version: String): <collection>
}
47 changes: 0 additions & 47 deletions openapi/paths/items/_collection/singleton/getSingleton.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions openapi/paths/items/_collection/singleton/index.yaml

This file was deleted.

48 changes: 0 additions & 48 deletions openapi/paths/items/_collection/singleton/updateSingleton.yaml

This file was deleted.

Loading