Comments (11)
@pietervogelaar could you elaborate in detail the request? I am familiar with HAL however I am not clear with regards to what you require from Swagger to support it.
from swagger-php.
At the moment a property in a model can have multiple models. For example a user can have multiple contacts.
The response in JSON for a user will be:
{
"id": "matthew",
"name": "Matthew Weier O'Phinney",
"contacts": [
{
"id": "mac_nibblet",
"name": "Antoine Hedgecock"
},
{
"id": "spiffyjr",
"name": "Kyle Spraggs"
}
]
}
But for HAL the response below is desired:
{
"_links": {
"self": {
"href": "http://example.org/api/user/matthew"
}
}
"id": "matthew",
"name": "Matthew Weier O'Phinney",
"_embedded": {
"contacts": [
{
"_links": {
"self": {
"href": "http://example.org/api/user/mac_nibblet"
}
},
"id": "mac_nibblet",
"name": "Antoine Hedgecock"
},
{
"_links": {
"self": {
"href": "http://example.org/api/user/spiffyjr"
}
},
"id": "spiffyjr",
"name": "Kyle Spraggs"
}
],
"website": {
"_links": {
"self": {
"href": "http://example.org/api/locations/mwop"
}
},
"id": "mwop",
"url": "http://www.mwop.net"
},
}
}
I think the annotations can stay the same, but the swagger bin should have a flag "hal_enabled" or something. So that child models will be enclosed in a "_embedded" key.
The _links key requires some annotation I think.
from swagger-php.
I agree, we would really need to get some support for JSON HAL into Swagger in order to be able to show the expected response in a correct way.
from swagger-php.
any progress on this?
from swagger-php.
Hi, folks! How are you? We also need this support in a project, does anyone have some new on this issue? Thank you, very much!
from swagger-php.
👍
from swagger-php.
+1
I am also struggling to figure out how to support JSON-API schema as well, seems support for arbitrarily nested attribute objects is not straight forward unless I'm missing something.
i.e. how would I support this response:
{
"data": [
{
"id": 1,
"type": "pet",
"attributes": {
"id": 1,
"name": "Dog"
},
"links": {
"count": "/pets/1/count"
}
}
]
}
from swagger-php.
@nnnnathann got similar issue with nested object. I've just created a class for each object in JSON and marked them in phpdoc annotations. Example based on your JSON:
class Pet {
/** @var PetAttrs */
var $attributes;
}
class PetAttrs {
var $id;
var $name;
}
from swagger-php.
@adambro @nnnnathann for nested definition, you can check this out. 😃
from swagger-php.
+1 for HAL support.
from swagger-php.
HAL support is outside the scope of the swagger-php project.
Feel free to experiment and create a swagger-php plugin, i'll gladly add that to the related projects page
from swagger-php.
Related Issues (20)
- The latest tag and release differ : 4.9.4 vs 4.10.0 ? HOT 1
- Unable to group HOT 9
- [Feature]: Append "tags" list via Operation attribute HOT 3
- Parameters in laravel seem a bit too troublesome HOT 4
- Improve processor reference
- Possible BC Break in 4.10.1 HOT 4
- Validation fails with repeated tags since v4.10.1 HOT 3
- Global unified configuration suggestions
- Filtering not done as expected HOT 4
- How to set deepObject properties type HOT 1
- removeAnnotation performance HOT 1
- Fatal error "Nesting level too deep - recursive dependency?" HOT 2
- Tags within api definition are not unique HOT 2
- No output on CLI HOT 1
- How to work with discriminator?
- Schema generation fails inside JsonContent HOT 2
- Schema generator add illegal request key under requestBody HOT 5
- Operation security is invalid
- Default OpenAPI Version from RootContext overwrites OpenAPI Version from OpenApi Property HOT 4
- Duplicate tags will not be filtered out HOT 8
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 swagger-php.