There is no way for an extension to implement a new PARAM_TYPE and therefor update the ApiSandbox to support that param type. For instance, if an extension wanted to create a json param type (that would allow JSON input) there would not be a way to do this (that I can find) and provide a custom input in the ApiSandbox (with codemirror, client and server-side validation, etc.)
I note that creating a new parameter type outside of core has many more requirements than just making it possible to create a widget in ApiSandbox. You'd also need to plug in to several places in the PHP code:
- ApiBase::getParameterFromSettings() for validation (T142080: HTTP API typechecking method is very confusing and intimidating may be related there)
- ApiStructureTest for parameter consistency checks in CI
- Possibly ApiHelp::getHelpInternal() to generate appropriate output for parameters using the new type
- Possibly ApiParamInfo::getModuleInfo() for similar data there
- Possibly ApiMain::modifyHelp() to add text to the datatypes documentation
As for ApiSandbox, we'd need some way for SpecialApiSandbox to load the extension's ResourceLoader module for extending ApiSandbox, and then probably use of mw.hook() from createWidgetForParameter() and possibly also ApiSandbox.PageLayout.prototype.makeWidgetFieldLayouts() to get that code called from the right places.
Does that make sense to you?
For some background, I was working on T209133 and I initially created a special page (and a non-localized custom route). But then I was thinking it might be better if it was a module in the action API (which would allow different return formats, etc.).
However, the UX on the Sandbox would be sub-optimal as the only allowed field for the query (GraphQL schema) and the variables (JSON) would be a text field. Ideally, I'd like to be able to create a graphql param type that would use something like https://github.com/graphql/codemirror-graphql in the sandbox and the extension would validate the param value and ensure that it's valid.
Anyways, feels like there are probably more use-cases than the one I have, so I abstracted the description. Ideally the Action API would expose a param type system that any extension would plugin to.