Skip to content

[3.0] Rework API response calls #364

@shalvah

Description

@shalvah

"Response calls", where the package attempts to call endpoints to retrieve a sample response, were removed in #356, because they had a number of issues (including mutating data in the database, authentication etc). They were also too closely tied to FormRequest parsing, which has been removed.

This ticket is to bring back response calls, as it is fairly tedious for developers to have to declare a sample response manually on each method. But we'll rework the implementation so it works. Some features of the new approach:

  • Last resort: @response and @transformer tags will take precedence.
  • Configurable: This can be turned off in the apidoc config
  • Safe: Response calls will be run in transactions so no db changes are persisted
  • Configurable environment: Response calls will use an app environment of documentation (configurable), and it will also be possible to specify environment variables for them (for instance, so your app can avoid making calls to external services), similarly to phpunit.xml env.
  • Authentication: I'm thinking of a way to specify some sort of authentication workflow to be run before hitting authenticated routes. Unfortunately, Laravel config files don't support Closures, so the best we can do is probably specifying a user ID to act as or authentication headers or query parameters to send.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions