tempest-framework icon indicating copy to clipboard operation
tempest-framework copied to clipboard

Improve API development

Open jseparovic1 opened this issue 10 months ago • 7 comments

In recent days it is more and more common to use PHP as a API layer with separate frontend. In this setup it is crucial to document API and allow better understanding between the teams.

While it is possible to achieve this using various packages (e.g. https://zircote.github.io/swagger-php/, https://github.com/thephpleague/openapi-psr7-validator), having official (and automated) integration would allow more flexibility.

Core features:

  • detect routes
  • detect route attributes
  • detect request properties (based on controller parameters)
  • detect response properties (via https://tempestphp.com/docs/framework/controllers/#response-objects?)
  • validate request according to schema before deserialization to object (long standing problem in api platform)
  • generate api docs

Inspiration and references

  1. https://fastapi.tiangolo.com/#example-upgrade FastAPI does this best in my opinion.
  2. https://api-platform.com/ provides much more features but in reality it might be to complex

jseparovic1 avatar Feb 28 '25 11:02 jseparovic1

I'm very much open to improve Tempest in this regard. I think I'm with you on the whole list, but we'd need to flesh it out a lot more and split in standalone tasks to get started on it.

brendt avatar Feb 28 '25 12:02 brendt

@brendt I agree, this is just the introduction of idea or tip of the iceberg. There are whole frameworks built around this concept. I posted it to spark some discussions and see what could be potential steps to start with this.

jseparovic1 avatar Feb 28 '25 16:02 jseparovic1

I've assigned it to the post-1.0 milestone, but we might pick it up earlier depending on the time available

brendt avatar Mar 01 '25 06:03 brendt

How can we organize this to determine some limits, what we want to support, what DX we want to achieve and so on ?

gturpin-dev avatar Mar 21 '25 13:03 gturpin-dev

How can we organize this to determine some limits, what we want to support, what DX we want to achieve and so on ?

For such a feature, I'd like people interested in tackling this to open a discussion first, discuss the features they want to implement and how, before doing any work—because there is a lot to do in this space

innocenzi avatar Mar 21 '25 14:03 innocenzi

On Discord, preferably :)

brendt avatar Mar 22 '25 05:03 brendt

My bad we already have opened the discussion here https://discord.com/channels/1236153076688359495/1345315356696121344

gturpin-dev avatar Mar 22 '25 11:03 gturpin-dev