Yes, it sounds like a horror splatter movie. But we'll just split files for you! -- BrocksiNet
You want to import the admin API from your Shopware instance, but it fails because it has circular dependencies and is way too big a JSON file to import all endpoints at once. This bun scripts can help you split the admin API into smaller pieces (by path or tags) so you can decide what you want to import.
Fist install dependencies:
bun installRun some command (see command reference below):
bun run splitTagsThis commands are avaiable
- Download admin API schema command
- Split by tags command
- Split by paths command
- Clean up command
- Lint command
This command downloads the OpenAPI schema file for the admin API and places it under ./input/admin-api.json. You can also place the file there manually and continue with the other commands.
Download OpenAPI Schema JSON file without BearerToken (from a local instance with default URL):
bun run downloadSchemaDefault URL is: http://localhost:8000/api/_info/openapi3.json?type=jsonapi
Download OpenAPI Schema JSON file without BearerToken (from a local instance):
bun run downloadSchema --urlToOpenApiSchemaJson="https://www.shopware.dev/api/_info/openapi3.json?type=jsonapi"Download OpenAPI Schema JSON file with BearerToken:
bun run downloadSchema --urlToOpenApiSchemaJson="https://demo-frontends.shopware.store/api/_info/openapi3.json?type=jsonapi" --bearerToken="eyJ0eXAiOiJKV1QiLCJhb...yourSecrectBearerToken"How to get a bearer token? Use the /oauth/token Endpoint, for more details see the Admin API Documentation about Authentication.
This creates smaller OpenAPI JSON files and groups the paths according to tags. For example, all endpoints with the tag “Tax Provider” are added to an OpenAPI schema file.
bun run splitTagsEach tag is written to a separate file.
You can provide a --filterByTag parameter to only export that specific tag.
bun run splitTags --filterByTag="Tax Provider"This command creates one OpenAPI JSON file for every path.
bun run splitPathsThe generation for all paths takes around ~45 seconds for current Shopware version 6.6.10.0.
You can provide a --filterByPath parameter to only export one specific path.
bun run splitPaths --filterByPath="/customer"Sometimes you need to clean up 🧼 things.
bun run cleanupDeletes all files from the folders ./output/admin/split/tmp and ./output/admin/bundeled.
bun run cleanup --everyThingDeletes all files and folders in the input and output folders.
bun run lintThis command will execute the redocly lint command on every file in ./output/admin/bundeled.
Workspace > Import Button > Select files from bundeled paths or tags > Import
Import Collection > OpenAPI V3 Spec > Select files from bundeled paths or tags > Select folder where you want to save the collection > Import
Created with happiness in mind 💙 by Shopware.