Comments (2)
Hello,
After following the getting started for Next.js, and customized for TypeScript, I am encoutering the same problem, running Directus v10.11.2 (through Docker).
I've found this issue as already been reported in #12921, and fixed by PR #12922, merged into main back in 2022.
It looks like the problem was on both operations read-all and read-one (aka. /items/global
and /items/global/{id}
), but has been fixed only on read-one.
Here is an extract of /server/specs/oas output, with a few JS comments:
"/items/global": {
"get": {
"summary": "List Items",
"description": "List the global items.",
"operationId": "readItemsGlobal",
"responses": {
"200": {
"description": "Successful request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "array", // <<<<<< data is an array, that's OK for collections but should be object for singleton (and "items" key removed)
"items": {
"type": "object",
"$ref": "#/components/schemas/ItemsGlobal"
}
}
}
}
}
}
}
}
}
},
"/items/global/{id}": {
"get": {
"summary": "Retrieve an Item",
"description": "Retrieve a single global item by unique identifier.",
"operationId": "readSingleItemsGlobal",
"responses": {
"200": {
"description": "Successful request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "object", // <<<<<< data is an object, that's OK for all (singleton and collections)
"$ref": "#/components/schemas/ItemsGlobal"
}
}
}
}
}
}
}
}
},
And the corresponding API JSON output:
read-all: http://example.com/directus/items/global
{"data":{"id":1,"title":"foo","description":"bar"}}
read-one: http://example.com/directus/items/global/1
{"data":{"id":1,"title":"foo","description":"bar"}}
We can clearly see that in both API, the JSON response for singleton is the same, but it's not what's state in the OpenAPI Spec.
I guess it's the OAS spec which is incorrect.
from directus.
Seeing a similar issue with a M2A item
. It's defined as an array in the spec, but really should be an object. That's what the REST API returns. e.g.
The endpoint returns the spec (snippet):
"ItemsStaticPagesSections":
{
"properties":
{
"collection":
{
"nullable": true,
"type": "string"
},
"id":
{
"nullable": false,
"type": "integer"
},
"item":
{
"items":
{
"oneOf":
[
{
"type": "string"
},
{
"$ref": "#/components/schemas/ItemsSectionHero"
},
{
"$ref": "#/components/schemas/ItemsSectionDifferentiators"
},
{
"$ref": "#/components/schemas/ItemsSectionCapabilities"
},
{
"$ref": "#/components/schemas/ItemsSectionTours"
},
{
"$ref": "#/components/schemas/ItemsSectionCaseStudies"
}
]
},
"nullable": true,
"type": "array"
},
"sort":
{
"nullable": true,
"type": "integer"
},
"static_pages_id":
{
"nullable": true,
"oneOf":
[
{
"format": "uuid",
"type": "string"
},
{
"$ref": "#/components/schemas/ItemsStaticPages"
}
]
}
},
"type": "object",
"x-collection": "static_pages_sections"
},
But the API returns (snippet):
NOTE: item
is NOT an array.
{
"collection": "section_hero",
"id": 1,
"item":
{
"background_image":
{
},
"background_transformation": 1,
"ctas":
[
],
"date_created": "2023-09-25T22:05:18.138Z",
"date_updated": "2024-04-03T00:37:53.299Z",
"id": 1,
"paragraph": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod",
"status": "published",
"title": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod",
"user_created": "c694c53f-161e-4340-98cf-f45e2fa3564b",
"user_updated": "c694c53f-161e-4340-98cf-f45e2fa3564b"
},
"sort": 1,
"static_pages_id": "49629f2a-4346-42b8-afd9-7977f78abe8d"
}
from directus.
Related Issues (20)
- Input default value not being stored correctly HOT 2
- Notification drawer: item count missing
- Server crashed after trying to access deleted file HOT 5
- Default values has some weird behaviours with translations
- App: List within a Dashboard does not render M2M fields
- Icon in Email Template - Liquid HOT 1
- You don't have permission to access collection \"directus_translations\" or it does not exist. Queried in root. HOT 3
- Prevent entering non valid default data to JSON fields HOT 3
- PermissionService does not work anymore since Directus 11 HOT 3
- Prevent entering non valid default data to JSON fields / format default value as valid JSON
- OpenAPI spec has a duplicate operationId HOT 3
- Difficult to update permissions with a long list and long collection names
- Rich text - open link new tab label is confusing HOT 3
- Update Extensions SDK Boilerplates to use Composition API
- Unexpected error in content page HOT 9
- Delete notifications from App HOT 2
- V-Color select interface doesn't support CSS-Variables HOT 2
- Generated OpenAPI schema uses the same `operationId` for two different operations HOT 1
- OpenApi Spec only returns GET paths HOT 1
- Local Directus doesn't show Permissions and Roles HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directus.