
* fix: make contrib docs landing message clearer to users * v5.1.1 to main (#21954) * enhancement: ui issues and french translations (#21633) * chore: ui issues and french translations * chore: added missing translation * chore: made it prettier * fix: test CI/CD building repo 2 times (#21740) * fix: do not display fill from locales if i18n no enabled (#21737) * fix: do not display fill from locales if i18n no enabled * chore: disable only if there is not i18n enabled * fix: send ids when connecting relations to update u&p user role (#21726) * fix:update role * fix: send entry id when connecting/disconnecting relations * fix: changed empty components wording (#21630) * fix: changed empty components wording * fix: updated selectors * fix: made it prettier * enhancement: add preview panel button (#21776) * chore: add test workflow filters for each test type (#21770) * chore: upgrade mysql2 package to 3.9.8 (#21795) * feat: add mapping property support for documentation plugin's open api generated docs (#21752) * feat: add mapping property support for documentation plugin's open API generated spec Dynamic zones are reflected in the OpenAPI docs generated as an anyOf. We can use a discriminator and mapping to improve the docs. * fix: missing one value enum for __component property * enhancement: extract logic to convert component names to OpenAPI names * chore: run prettier write on clean schema attributes --------- Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com> * chore: fix mysql workflow (#21801) * chore: upgrade koa/router to 12.0.2 (#21802) * Update "upgrade major" rules (#21745) * fix: broken list view pagination (#21800) * fix: broken list view pagination * chore: add list view pagination e2e test * enhancement: add copy preview url button (#21780) * enhancement: add copy preview button * chore: remove useClipboard from upload plugin * Add <latest> Upgrade Command (#21754) * Make locale/localizations private for non-localized cts (#21495) * chore: upgrade sendgrid-mail to 8.1.3 (#21797) * chore: re-enable history e2e tests (#21739) * fix: reenable history api tests fix: flaky findAndClose fix: close notifications * chore: add test workflow filters for each test type * chore: fix node versions * fix: match format of test.yml * revert: don't add test_result to skipped_tests * fix: add new outputs vars --------- Co-authored-by: Ben Irvin <ben@innerdvations.com> * fix: search by numeric numbers in a relation (#21873) * Sort Generated Content-Types and Components Definitions (#21868) * fix(e2e): remove webkit skip conditions (#21611) * fix(e2e): remove webkit skip conditions * chore: revert uniqueness spec to test others on ci * fix(e2e): ctb navigation * chore: ci config to speed up testing * chore: revert lock * chore(e2e): wip add webkit waiting * chore: single out history spec changes for ci * chore(e2e): use new webkit navigation for all affected test files * chore(e2e): revert e2e ci config so all tests run again * chore(e2e): temp skip uniqueness to test others * chore(e2e): revert so all tests run again * chore(e2e): re-skip uniqueness in webkit * chore(e2e): revert workflow yaml * chore(e2e): pr feedback --------- Co-authored-by: Ben Irvin <ben.irvin@strapi.io> * fix(strapi/types): add Attribute column type (#21858) * chore: add preview tracking (#21913) * chore: upgrade plop to 4.0.1 (#21798) * chore: upgrade cookie to 0.7.1 (#21833) * enhancement: DTS assert count of items sent and received is equal (#21900) * feat: added a count, start, finish counts to compare data recieved with data sent * feat: refactoring * feat: refactoring * v5.1.1 --------- Co-authored-by: Lucas Boilly <45385696+lucasboilly@users.noreply.github.com> Co-authored-by: Boegie19 <34578426+Boegie19@users.noreply.github.com> Co-authored-by: Rémi de Juvigny <8087692+remidej@users.noreply.github.com> Co-authored-by: Ben Irvin <ben.irvin@strapi.io> Co-authored-by: Pedro Cerejo <pedro.cerejo@tecnico.ulisboa.pt> Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com> Co-authored-by: Jean-Sébastien Herbaux <jean-sebastien.herbaux@epitech.eu> Co-authored-by: Rémi de Juvigny <remi.dejuvigny@strapi.io> Co-authored-by: Ben Irvin <ben@innerdvations.com> Co-authored-by: Andrei Luca <1881266+iamandrewluca@users.noreply.github.com> Co-authored-by: Bassel Kanso <basselkanso82@gmail.com> * fix: prettier --------- Co-authored-by: Pierre Wizla <pwizla@users.noreply.github.com> Co-authored-by: Alexandre BODIN <alexandrebodin@users.noreply.github.com> Co-authored-by: Lucas Boilly <45385696+lucasboilly@users.noreply.github.com> Co-authored-by: Boegie19 <34578426+Boegie19@users.noreply.github.com> Co-authored-by: Rémi de Juvigny <8087692+remidej@users.noreply.github.com> Co-authored-by: Ben Irvin <ben.irvin@strapi.io> Co-authored-by: Pedro Cerejo <pedro.cerejo@tecnico.ulisboa.pt> Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com> Co-authored-by: Jean-Sébastien Herbaux <jean-sebastien.herbaux@epitech.eu> Co-authored-by: Rémi de Juvigny <remi.dejuvigny@strapi.io> Co-authored-by: Ben Irvin <ben@innerdvations.com> Co-authored-by: Andrei Luca <1881266+iamandrewluca@users.noreply.github.com> Co-authored-by: Bassel Kanso <basselkanso82@gmail.com>
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
- documentationVersion // 1.0.0
- documentation
- my-api
- plugins
- ...
- documentation
- documentation
- 1.0.0
- full_documentation.json
- 1.0.0
- documentation
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.