https://github.com/vaporexampleslab/example-so-vaporjsonresponse
Working example for StackOverflow question "Making Vapor API response JSON API Spec compliant".
https://github.com/vaporexampleslab/example-so-vaporjsonresponse
Last synced: 3 months ago
JSON representation
Working example for StackOverflow question "Making Vapor API response JSON API Spec compliant".
- Host: GitHub
- URL: https://github.com/vaporexampleslab/example-so-vaporjsonresponse
- Owner: VaporExamplesLab
- License: mit
- Created: 2018-09-08T21:36:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-05-31T03:39:13.000Z (about 5 years ago)
- Last Synced: 2024-12-31T21:26:27.235Z (over 1 year ago)
- Language: Swift
- Homepage: https://stackoverflow.com/questions/52232746/making-vapor-api-response-json-api-spec-compliant
- Size: 10.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Example-SO-VaporJsonResponse
`Example-SO-VaporJsonResponse` provides a working example for the StackOverflow question ["Making Vapor API response JSON API Spec compliant"](https://stackoverflow.com/questions/52232746/making-vapor-api-response-json-api-spec-compliant).
Each `class` and/or `struct` in the compound object `ApiResponse` complies with the `Content` protocol. The `Content` protocol includes the `Codable` protocol for JSON decoding and encoding.
The `POST` was checked with the [RESTed](https://apps.apple.com/us/app/rested-simple-http-requests/id421879749) macOS application using the file ["Dish.request"](Dish.request).
``` sh
curl -i -X POST "http://127.0.0.1:8080/api/dish" \
-H "Content-Type: application/json" \
-d '{"course": "salad", \
"description": "flavorful Southwestern ethos", \
"price": 1.82, "title": "Aztec Salad"}'
```