Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically generate OpenAPI compliant documentation #489

Open
daryledesilva opened this issue Feb 24, 2020 · 11 comments
Open

Automatically generate OpenAPI compliant documentation #489

daryledesilva opened this issue Feb 24, 2020 · 11 comments

Comments

@daryledesilva
Copy link
Contributor

Hi, do you have any plans on adding a new feature that adds support for generating OpenAPI compliant documentation out of the api configuration? It would be really nice to have!

@lindyhopchris
Copy link
Member

Hi! Yes this is something I'd love the package to do at some point... but time is currently my enemy! I think the refactoring mentioned in #411 needs to be done first, because I don't think it would be sensible attempting to do the OpenAPI stuff now when I'm about to refactor the internals of the package.

@daryledesilva
Copy link
Contributor Author

I just saw #411 yes it makes sense for that to be done first. okay thank you for the response, and maintaining the project! awesome job 😁

@lironesamoun
Copy link

Hi ! Any updates for generating a documentation for the API ? =D

@lindyhopchris
Copy link
Member

No updates yet, it's dependent on implementing the new version of the package. I'm planning a sprint on that probably in November as I'm expecting to have a week or so between paid work.

@lindyhopchris
Copy link
Member

The new package is now available - laravel-json-api/laravel see https://laraveljsonapi.io

I'd love to add Open API documentation generation.... but time is still a problem for me. If there are any volunteers who would like to step forward to take this on as a project, then that would be superb - just let me know.

@lindyhopchris lindyhopchris changed the title add support for generating OpenAPI compliant documentation Automatically generate OpenAPI compliant documentation Feb 5, 2021
@happyDemon
Copy link

I'm willing to have a go at this over the weekend

@cruzvale33
Copy link

Some updates for the API documentation generation?

@lindyhopchris
Copy link
Member

It won't be added to this package, as this package (cloudcreativity/laravel-json-api) is legacy. Still an intent to add it to the new package (laravel-json-api/laravel) but realistically someone needs to step up to contribute it as it's difficult for me to prioritise at the moment.

@nelson6e65
Copy link

nelson6e65 commented Apr 19, 2023

There is a WIP package working on a tool for laravel-json-api/laravel: https://github.com/swisnl/openapi-spec-generator

@genyded
Copy link

genyded commented Jul 21, 2023

This can be accomplished/addressed with https://scribe.knuckles.wtf/laravel/documenting/custom-endpoints. It's not quick and easy but then none of the packages that help with API docs using docblocks and such are.

This one however allows you to create create YAML files (they can Camel files) and it will respect (not overwrite) and integrate those during doc generation/regeneration. It supports OPENAPI generation/creation and even has a nice JS based 'Try It' feature should you choose to enable it.

Those YAML files can be used to pretty easily document things like JSON:API endpoints or anything that does not follow the standard Laravel conventions for route/controllers/requests, and so on that most of the doc generators try to parse when generating docs.

Basically instead of the typical docblocks, you create one of these yaml files for each JSON:API 'group' of endpoints you want to document along with the details for each endpoint in that group. Then upon doc generation/regeneration, those get parsed instead of routes and/or docblocks to provide the docs and examples for the JSON:API endpoints. You can also use the other methods (routes/docblocks) for non-json:api endpoints in conjunction with your custom yaml files (in fact doc generation creates or appends to them to propagate them into the docs when you generate anyway).

I/we are not associated with Laravel Scribe at all and this is not a plug for it. It just happens to be what we landed on after a ton of trial and error trying to solve the exact issue of API documentation for the JSON:API or any other non-typical Laravel integrations.

Once you get familiar with the Scribe package and the foundation set up with everything the way you like it, we actually find much faster and easier then docblocks anyway. You just have to decide on your initial groups and which endpoints you want where and then add/append to them as you go. There is a YAML file for each 'group'.

@genyded
Copy link

genyded commented Jul 21, 2023

Oh and I forgot to mention another option that may work better for some teams or people who hate YAML. If you happen to be using the tests that Laravel JSON:API provides and have tests for all the endpoints that you want to document, there is a Scribe TDD plugin https://github.com/ajcastro/scribe-tdd that can be added to generate the docs (and OPENAPI spec) from the tests instead of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants