Invalid OpenApi documentation generated

System Information
  • Strapi Version: 4.9.0
  • Operating System: Windows 11
  • Database: sqlite
  • Node Version: 18.15.0
  • NPM Version: 9.5.0
  • Yarn Version: 1.22.19
  • OpenApi generator version: typescript-fetch 6.5.0

Hiya strapi-community,

I’ve added the documentation plugin to Strapi to generate OpenApi-compliant documentation. The documentation is generated and can be viewed on the Swagger documentation page but I run into a problem when I try to use the typescript-fetch OpenApi generator to generate API files and interfaces.

Before posting an issue on Github I thought I could ask in this forum since I’m not sure if I just did something wrong :slight_smile:

The command I am using is: "openapi-generator-cli.cmd generate -i .\\src\\extensions\\documentation\\documentation\\1.0.0\\full_documentation.json -g typescript-fetch -o .\\src\\api\\strapi\\"

and I get the same errors when I use the validate command: "openapi-generator-cli.cmd validate -i .\src\extensions\documentation\documentation\1.0.0\full_documentation.json"

Output is:

Validating spec (.\src\extensions\documentation\documentation\1.0.0\full_documentation.json)
Errors:
        - attribute components.schemas.Error.items is missing
        - info.contact.no-website
        - attribute components.schemas.Error.items is not of type `object`
Warnings:
        - Unused model: UsersPermissionsRoleListResponseDataItemLocalized
        - Unused model: UsersPermissionsRoleListResponse
        - Unused model: UsersPermissionsPermissionListResponseDataItemLocalized
        - Unused model: UsersPermissionsUserResponseDataObject
        - Unused model: UploadFolderListResponseDataItem
        - Unused model: UsersPermissionsUserResponse
        - Unused model: UsersPermissionsUserRequest
        - Unused model: UsersPermissionsPermissionResponseDataObjectLocalized
        - Unused model: UsersPermissionsRoleResponse
        - Unused model: UploadFileResponseDataObjectLocalized
        - Unused model: UsersPermissionsRoleResponseDataObjectLocalized
        - Unused model: UploadFolderResponseDataObjectLocalized
        - Unused model: UploadFileRequest
        - Unused model: UsersPermissionsRoleRequest
        - Unused model: UploadFolderRequest
        - Unused model: UsersPermissionsRoleResponseDataObject
        - Unused model: UsersPermissionsPermissionListResponseDataItem
        - Unused model: UsersPermissionsPermissionResponseDataObject
        - Unused model: UsersPermissionsUserListResponseDataItem
        - Unused model: UsersPermissionsUserListResponse
        - Unused model: UsersPermissionsPermissionRequest
        - Unused model: UploadFolderResponseDataObject
        - Unused model: UploadFolderListResponse
        - Unused model: UsersPermissionsUserListResponseDataItemLocalized
        - Unused model: UploadFolderResponse
        - Unused model: UsersPermissionsPermissionListResponse
        - Unused model: UploadFileListResponseDataItemLocalized
        - Unused model: UsersPermissionsRoleListResponseDataItem
        - Unused model: UsersPermissionsPermissionResponse
        - Unused model: UsersPermissionsUserResponseDataObjectLocalized
        - Unused model: UploadFolderListResponseDataItemLocalized

[error] Spec has 3 errors.

I’ve tried it with and without specifying a settings.json (copied and slightly modified from: API Documentation | Strapi Documentation. The output above was generated when using:

{
  "openapi": "3.0.2",
  "info": {
    "version": "1.0.0",
    "title": "DOCUMENTATION",
    "description": "API documentation for the strapi backend",
    "termsOfService": "No terms of service available yet.",
    "contact": {
      "name": "team",
      "email": "no-email@****.ch",
      "url": "no-website"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "x-strapi-config": {
    "path": "/documentation",
    "showGeneratedFiles": true,
    "generateDefaultResponse": true,
    "plugins": [
      "email",
      "upload",
      "users-permissions"
    ]
  },
  "servers": [
    {
      "url": "http://localhost:1337",
      "description": "Development server"
    }
  ],
  "externalDocs": {
    "description": "Find out more",
    "url": "https://strapi.io/documentation/"
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {},
  "tags": [],
  "components": {}
}

I saw that in the Error schema there is an items field but not at the place where it was not found (instead of components.schemas.Error.items there is components.schemas.Error.properties.data.oneOf[1].items, but not sure if that is relevant.
And the second error I’m just surprised it tries to find an object that is named like the website.

Thanks in advance for any help!