-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
Node Version
22.20.0
NPM/Yarn/PNPM Version
NPM 10.9.3
Strapi Version
5.25
Operating System
Linux (Debian/Ubuntu)
Database
SQLite
Javascript or Typescript
Javascript
Reproduction URL
No response
Bug Description
I'm using the new strapi openapi generate
command to output the REST API schema to a JSON. I have a collection type with a dynamic zone field with multiple components. The field is exported in the schema, but its type is just {}
and the Component schemas aren't exported.
{
"openapi": "3.1.0",
"x-powered-by": "strapi",
"x-strapi-version": "5.25.0",
"info": {
"title": "my-homepage-strapi",
"description": "API documentation for my-homepage-strapi v0.1.0",
"version": "0.1.0"
},
"paths": {
/*...*/
"/articles": {
"get": {
"operationId": "article/get/articles",
/*...*/
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
/*...*/
"blocks": {
"description": "A dynamic zone field",
"type": "array",
"items": {}
/*...*/
As soon as I create a component field (not dynamic zone) in a Content Type, the Schema of the component is included in the schema output. The schema of the dynamic zone unfortunately is still {}
.
Steps to Reproduce
- Create two components in the content type builder
- Create a content type with a dynamic zone that includes these components
- Run
strapi openapi generate --output schema.json
. The resulting file will not contain any information about the components that were created and referenced. - Create another content type with a component field that references one of the components
- Run
strapi openapi generate --output schema2.json
. The resulting file will contain information about the component, but the info about the dynamic zone will still be empty
Expected Behavior
The dynamic zone field should also have references to the components. OpenAPI seems to have a oneOf keyword, which I think would be the right tool for the job. maybe the __component
field can also be included in the schema.
Logs
Code Snippets
No response
Media
No response
Additional information
Why I need this info: In my frontend, i generate TypeScript definitions from the OpenAPI schema. That way, I can have type-safety and autocomplete when handling responses from strapi.
Thank you very much!
Confirmation Checklist
- I have checked the existing issues for duplicates.
- I agree to follow this project's Code of Conduct.