Marc Roig 54430efa43
Releases/5.6.0 (#22471) (#22472)
* feat: add content preview (remove future flag)

* chore: fix tests

* test(e2e): components and dz in create collection type (#22374)

* feat(content-manager): add syntax highlighting in the code block type in the Blocks field original solution (#22332)

* feat: install prismjs

* feat(content-manager): add highlights to code block using Prismjs

* feat(content-manager): remove screen debug

* feat(content-manager): extends render leaf props

* feat(content-manager): fix build issue

* feat(content-manager): move prismjs theme import

* feat(content-manager): change theme

* feat(content-manager): theme import minimized

* feat(content-manager): import prismjs types

* feat(content-manager): change gh action config

* feat(content-manager): revert the admin bundle size code

* feat(content-manager): remove console log

* feat(content-manager): change import theme

* feat(content-manager): remove theme

* feat(content-manager): change imports

* feat(content-manager): change prismjs import

* feat(content-manager): try to find the issue in gh action

* feat(content-manager): add theme test

* feat(content-manager): add packup css plugin

* feat(content-manager): remove rollup

* feat(content-manager): add change threshold

* feat(content-manager): import Prism in Code component

* feat(content-manager): remove prismjs

* feat(content-manager): install prismjs

* feat(content-manager): add prismjs theme

* feat(content-manager): install prismjs in admin

* feat(content-manager): try to change Prism import

* feat(content-manager): add config file

* feat(content-manager): add prismjs vite config

* feat(content-manager): change rollup options

* feat(content-manager): modify vite config

* feat(content-manager): add manually prismjs

* feat(content-manager): revert prismjs logic

* feat(content-manager): fix build errors

* feat(content-manager): solve failing fe unit tests

* feat(content-manager): add threshold

* feat(content-manager): fix import default

* feat(content-manager): change vite config

* feat(content-manager): add vite plugin prismjs

* feat(content-manager): update vite config

* feat(content-manager): fix issue decorate

* chore: add prism in admin deps

* feat(content-manager): replace original solution prismjs

* feat(content-manager): remove useless prismjs dep in admin

* feat(content-manager): change prismjs version

* feat(content-manager): remove vite-plugin-prismjs

* feat(content-manager): remove useless duplications in constants file

* feat(content-manager): move some files

* feat(content-manager): fix review comments

* feat(content-manager): remove useless importPath property

---------



* chore(deps): bump nanoid from 3.3.7 to 3.3.8 in /docs (#22389)

Bumps the npm_and_yarn group with 1 update in the /docs directory: [nanoid](https://github.com/ai/nanoid).


Updates `nanoid` from 3.3.7 to 3.3.8
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.3.7...3.3.8)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-type: indirect
  dependency-group: npm_and_yarn
...




* security(deps): bump nanoid to 3.3.8 in yarn.lock (#22397)

* enhancement: update purchase page links (#22419)

* enhancement: update purchase page links

* chore: remove local tests

* chore: add newline

* enhancement(database): add repair manager with component deletion fix (#22267)

* fix: preview back button behavior (#22432)

* fix: multiple requests locale (#22273)

* fix: multiple requests locale

* fix: actions request

* fix: properly load locales

* fix: add status to localizations

* fix: remove unused types

* fix: front tests

* fix: add validation fields into localizations

* fix: validatable attributes

* fix: select nested fields when populating localizations

* fix: uncomment localizations populate

* fix: document-metadata

* fix: empty populate

* fix: revert to original proposal

* fix: do not select document ids on components (#22330)

* fix: do not select document ids on components

* chore: unit test

* fix: metadata test

* fix: populate

* fix: default fields

* fix: show current locale when bulk publishing

* fix: create locale

* Update packages/core/content-manager/server/src/services/document-metadata.ts



---------



* fix: add component button style (#22425)

* fix: add-component-button-style

* fix: made it prettier

* fix: optimizations

* fix(blocks): various ui issues (#22423)

* fix: blocks-ui-fixes

* fix: made it prettier

* fix: optimizations

* fix: remove double conversion that causes date shift (#22410)

* fix: remove double conversion that causes date shift

* fix: remove useless files

* release: 5.6.0

* Revert "release: 5.6.0"

This reverts commit 77ad0efc79afd9777d140f84e8abc47cda26d1d9.

* release: 5.6.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Rémi de Juvigny <remi.dejuvigny@strapi.io>
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Rémi de Juvigny <8087692+remidej@users.noreply.github.com>
Co-authored-by: Simone <startae14@gmail.com>
Co-authored-by: Alexandre Bodin <bodin.alex@gmail.com>
Co-authored-by: Convly <jean-sebastien.herbaux@epitech.eu>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maxime Castres <17828745+Mcastres@users.noreply.github.com>
Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com>
Co-authored-by: Lucas Boilly <45385696+lucasboilly@users.noreply.github.com>
Co-authored-by: Ziyi <ziyi.yuan@strapi.io>
2024-12-19 09:27:12 +01:00
..
2024-07-31 14:22:27 +02:00
2024-12-19 09:27:12 +01:00
2024-03-21 18:20:12 +01:00

Plugin documentation

This plugin automates your API documentation creation. It basically generates a swagger file. It follows the Open API specification version 3.0.1.

Usage

  • Config
  • Creating a new documentation version
  • Generated files
    • full_documentation.json structure
  • Overriding the suggested documentation
  • FAQ
    • How does it generate the others plugins documentation ?
    • I have created a route into a common API (like product) that query another model. How to automate this?
  • TODO

Config

Create a settings.json file located in src/extensions/documentation/config folder where you can specify all your environment variables, licenses, external documentation and so one... You can add all the entries listed in the specification.

NOTE if you need to add a custom key you can do it by prefixing your key by x-{something}

Creating a new documentation version

In order to create a new version you need to change the info.version key in the settings.json file.

This will automatically create a new version.

Generated files

When you start your server with this plugin installed it will automatically create the following files in your APIs (we will see how it works for the plugins).

  • api
    • my-api
      • documentation
        • documentationVersion // 1.0.0
          • my-api.json // File containing all the identified path
          • unclassified.json // File containing the manually added paths
          • overrides // Folder to override the generated documentation
  • plugins
    • ...
    • documentation
      • documentation
        • 1.0.0
          • full_documentation.json

full_documentation.json

The combined documentation is merged into the full_documentation.json file and it's located in src/extensions/documentation/documentation/{version}/full_documentation.json

It has the following structure

{
  "openapi": "3.0.0", // do not change this version
  "info": {
    "version": "1.0.0" // change this line to create a new version
    ...
  },
  "x-strapi-config": {
    "showGeneratedFiles": true // Do not change this line at the moment...
  },
  "servers": {}, // Your servers config (it will be automated)
  "externalDocs": {},
  "paths": {}, // All your Api routes
  "tags": [], // Group of route
  "components": {} // Default generated components and custom ones
}

Overriding the suggested documentation

Currently the plugin writes a json file for each API.

In order to customize the responses or to add information to a path you need to create a file in the associated overrides/<file-name>.json (the name of the file matters so make sure they are similar). Then you just need to identify the path you want to modify. You can modify the default generated tags by adding a new one at the end of the file. Same for the components.

NOTE 1

Overriding the full_documentation.json is a bad idea since it will be regenerated each time you change a model.

NOTE 2

You can modify the tags, paths, and components keys on the generated documentation by providing replacement values. You can see how the API is used in the users-permissions plugin: packages/plugins/users-permissions/server/register.js

FAQ

How does it generate the others plugins documentation ?

In other to reference a plugin's route into the documentation you need to add a description key in the config object.

For example this is the plugin email routes.json file

{
"routes": [
  {
    "method": "POST",
    "path": "/",
    "handler": "Email.send",
    "config": {
      "policies": [],
      "description": "Send an email",
      "tag": {
        "plugin": "email",
        "name": "Email"
      }
    }
  },
  {
    "method": "GET",
    "path": "/environments",
    "handler": "Email.getEnvironments",
    "config": {
      "policies": []
    }
  },
  {
    "method": "GET",
    "path": "/settings/:environment",
    "handler": "Email.getSettings",
    "config": {
      "policies": []
    }
  },
  {
    "method": "PUT",
    "path": "/settings/:environment",
    "handler": "Email.updateSettings",
    "config": {
      "policies": []
    }
  }
]
}

In this file we have only one route that we want to reference in our documentation (/). Usually, the tag object is used for the SWAGGER UI, it will group this route under the Email - Email dropdown in the documentation. Furthermore, the algorithm will try to find the model to generate the best response possible. If the model is unknown it generates a response like the following { foo: "string" } that you can easily override later.

There's another property to guide the algorithm to create the best response possible, the actionType key. When we can't know by the controller name the type of the returned response (like find and findOne) you can specify it with this key. There's an example in ./plugins/users-permissions/config/routes.json.

I have created a route in a common API (like product) that query another model. How to automate this ?

You can use the tag key in your route. If you provide a tag which is a string like "tag": "Product" the algorithm will know that the end-point retrieves data from the Product table. Creating a tag object { "tag": { "name": "User", "plugin": "User-Permissions } } will result in generating a response with the User model from the plugin users-permissions.


Each entry of the object is easily customisable take look at the users-permissions ones they are a good example on how to do it.