Slimframework v4 & Swagger

Hi,

I’m wondering if there’s a way to speed up the swagger file generation when building an API with SlimFramework v4 ?

I’ve an existing API with a lot of methods but no swagger documentation.

I’m trying to use https://github.com/zircote/swagger-php.

Writing by hand all the annotation seems super dumb and boring while most of the info are already coded and probably discoverable.

Any tips ? or I really should write everything by hand?

Thanks,
P.

It sucks to write it by hand, but I feel like that’s a limitation we have to live with in PHP since it’s not a proper statically typed language (take a look at swashbuckle for .NET if you want something automatic). I prefer writing openapi specs directly rather than using the php annotation library you mentioned - less indirection.

A useful tool is the league/openapi-psr7-validator middleware that validates requests and responses automatically, to ensure they conform with an openapi spec file.

1 Like

well I’d rather put the documentation as close as possible to the code, so the doctrine way suits me well.

too bad,

There’s this project

but it works with symphony.