Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

OpenAPI schema generation - no types exported for Dynamic Zone field #24560

Copy link
Copy link
@bb1950328

Description

@bb1950328
Issue body actions

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

  1. Create two components in the content type builder
  2. Create a content type with a dynamic zone that includes these components
  3. Run strapi openapi generate --output schema.json. The resulting file will not contain any information about the components that were created and referenced.
  4. Create another content type with a component field that references one of the components
  5. 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

tif-calin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.