Comments (4)
As the creator of Laravel JSON:API, I'm interested to see what people say here.
FYI there is an intention for Laravel JSON:API to produce Open API specs. The only thing that's blocking it really is available time on open source work. Plus I find it difficult to prioritise, because the personal projects I use Laravel JSON:API don't (at the moment) need OpenAPI spec files.
There's a rather lengthy discussion about it here, in case you haven't seen it: laravel-json-api/laravel#19
from json-api.
There's a rather lengthy discussion about it here, in case you haven't seen it: laravel-json-api/laravel#19
I have seen that issue and tried it out with the example project of Laravel JSON:API. It generates an OpenAPI spec file as expected, which does work but gets cumbersome really quickly.
Generating a client from that, currently doesn't work really well as the response bodies are incomplete (for example: included
is missing. I know, it's still in development). But even if it were complete I would have to extract data from the included
array using relationships
data.
Example
const postResponse = await PostsService.postsShow(1, ['author']); // the array represents the "include" query parameter
const author = postsResponse.included
.filter((i) => i.type === postResponse.relationships.author.data.type)
.find((i) => i.id === postResponse.relationships.author.data.id)
I know there are tools like json-api-merge. But they would only return me an untyped (any
-object).
Our current solution
Currently we use Laravel-Data to work with data in regards to our API. We have a laravel package that generates an OpenAPI spec file using information from our controllers, attributes and the DTO class structures.
We then generate a Typescript client from that OpenAPI spec file and use that to interact with our backend. One of the major benefits is, that if a backend dev changes something in regards to the API, we immediately see where we have to adjust code in our frontend due to TypeScript or SAST throwing errors at us.
from json-api.
Two patterns are available to document your JSON:API as already mentioned in this thread:
- Human readable documentation focused on existing a) entry points to the API, b) available resource objects and the attributes and relationships of those, and 3) implementation-specific semantics (e.g. filtering strategy, supported side-loading of related resources etc.).
- Machine readable documentation using OpenAPI specification.
An API could provide only one of them, both or even none. The documentation could be written by hand or generated automatically. Existing tooling highly depends on the tech stack chosen by the project. This is nothing to be solved by the JSON:API specification itself in my opinion.
from json-api.
I'm going to close this issue. Feel free continuing the topic in the discussion forum.
from json-api.
Related Issues (20)
- consider support for implementation-specific members HOT 2
- JSON-LD integration example HOT 1
- Clarify intent of links member HOT 1
- 1.1 spec disallows e.g. filter[author.name] HOT 4
- Inclusion of related resources for heterogeneous collections
- PrimaryResourceType not to be null at this point HOT 1
- Create/update relationships having attributes? HOT 3
- ember-data link on implementations page is broken HOT 2
- Bulk delete as either extention or implementation HOT 4
- Extend Spec To Allow Creation of Multiple Resources in One API Call HOT 1
- Profiles should be allowed to define query parameters HOT 5
- JSONRenderer does not extract includes from PolymorphicModelSerializer properly HOT 1
- Version 1.1 is incomplete about where extension members are allowed.
- Suggestion: Add GitHub topics to help with discoverability
- Semantics of PATCHing attributes HOT 8
- Explain intent of local identifiers in a note in the spec
- https://jsonapi.org/schema#/definitions/failure 404 error HOT 3
- v1.1 docs mix location of "links" for GET vs POST HOT 1
- Bug: Update twitter icon from Bird to X
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-api.