Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bump-sh-examples/laravel-design-first
Create your OpenAPI then use it to power your application, covering both request validation and contract testing.
https://github.com/bump-sh-examples/laravel-design-first
api-documentation api-rest laravel laravel-framework laravel10 openapi openapi3 sample
Last synced: about 1 month ago
JSON representation
Create your OpenAPI then use it to power your application, covering both request validation and contract testing.
- Host: GitHub
- URL: https://github.com/bump-sh-examples/laravel-design-first
- Owner: bump-sh-examples
- License: other
- Created: 2024-01-15T23:12:27.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-11T16:04:35.000Z (8 months ago)
- Last Synced: 2024-09-28T20:02:29.550Z (about 2 months ago)
- Topics: api-documentation, api-rest, laravel, laravel-framework, laravel10, openapi, openapi3, sample
- Language: PHP
- Homepage: https://bump.sh/bump-examples/hub/code-samples/doc/laravel-design-first
- Size: 99.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE_CC-BY-NC-SA-4.0
Awesome Lists containing this project
README
# Laravel Code First
This repository was built as sample code for the Bump.sh guide on _[Using OpenAPI to simplify building and testing Laravel APIs](https://docs.bump.sh/guides/openapi/design-first-laravel/)_. Learn to use the API Design First workflow, and simplify your Laravel code by not having to repeat your API contract in validation and contract testing as well as documentation. Just do it once, make easy code, then pop it all onto Bump.sh to have [great API documentation](https://bump.sh/bump-examples/hub/code-samples/doc/laravel-design-first).
## Usage
Clone the repository down to give it a try.
```
# Set everything up
$ composer install# Start the server
$ php artisan serve# Poke the API and get automated errors
$ curl -X POST http://localhost:8000/api/widgets \
-H "Content-Type: application/json" \
-d '{"name" : "Replicator"}'{
"errors": {
"requestBody": [
"description is a required field"
]
},
"title": "Request payload failed validation",
"type": "about:blank",
"status": 400
}
```Give it a try, play around with the OpenAPI, and see how it responds to different scenarios.
Then you can run `composer test` to see if the API responses match what OpenAPI expect, which when implemented in your application will help make sure your API is actually doing what your docs are saying, or make sure your docs are saying what your API is doing, whichever way round you prefer to think of it.
Preview how the API reference docs look [on Bump.sh](https://bump.sh/bump-examples/hub/code-samples/doc/laravel-design-first).
## License
The contents of this repository are licensed under [CC BY-NC-SA
4.0](./LICENSE_CC-BY-NC-SA-4.0).