Comments (5)
That's a good idea!
From the top of my head, I don't know if the Swagger/Open-API spec permits this type of referencing. If it does, than implementing it should be easy. If it does not, it could still be implemented but will take a bit more effort.
The current "support" for array references is probably a bug; this was not intentional and has to do with the way SG handles types. Could you describe what you think the result should be and what SG currently generates?
I'll try to find some time this weekend to look into this.
from phpswaggergen.
I think Swagger does permit, at least at swagger editor. Consider the following yaml:
swagger: '2.0'
info:
title: API
description: Description
version: "1.0"
host: myhost.com
schemes:
- https
basePath: /
consumes:
- application/json
produces:
- application/json
paths:
/stations:
get:
description: |
Returns list of station for a given supplier id.
responses:
200:
description: An Object defining response from Station
schema:
$ref: '#/definitions/Stations'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
definitions:
Error:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
fields:
type: string
Address:
description: Object defining Address.
properties:
address_line1:
type: string
address_line2:
type: string
city:
type: string
state:
type: string
postal_code:
type: string
country_code:
type: string
phone:
type: string
fax:
type: string
Stations:
type: array
items:
$ref: '#/definitions/Station'
Station:
description: Detailsof station.
properties:
id:
type: integer
name:
type: string
address:
$ref: '#/definitions/Address'
As you can see, the Stations schema contains and array of Station objects (that is why I was expecting that @rest\property array(address)
to work fine). At the same time, Station contains a reference to the address object. This way, editor.swagger.io does not complaints and produces the following output:
I can get SG to generate an array of referenced objects, but fail to generate a referenced object within another referenced object.
Hope this helps, please let me know if you need additional information. I would like to contribute, but at this time I find myself with very limited time :( I'm also attaching YAML above converted to JSON
Thanks!
swagger (1).json.zip
from phpswaggergen.
This was a pretty simple fix, adding some useful functionality.
Thanks for the issue and all the example code, which greatly helped finding and fixing this issue.
Fix and unittest coverage included in 2.3.7
Please let me know if this works for you.
from phpswaggergen.
Awesome!
Will update and test, and will let you know.
from phpswaggergen.
Confirming the generated docs work as expected in the swagger editor using version 2.3.7. Thanks
from phpswaggergen.
Related Issues (19)
- Support for string:uuid HOT 9
- object(xxxx:array(),xxxxx:array()) throws exception HOT 4
- Property definitions should accept further (type-specific) commands HOT 1
- HEAD operation is not supported HOT 3
- Multiple definitions exist for class TestCase HOT 1
- @rest/require should create object on each item HOT 1
- Feature request for support example attribute for elements HOT 4
- Suppress 'exclusive(Max|Min)imum' for unbounded range ends
- additionalProperties support HOT 5
- Comments ignored with docblock (/**) syntax HOT 3
- Preserve EOL to be able to format description HOT 2
- Insert content of preprocessor variable into documentation
- Associative arrays are cast to objects, not arrays HOT 2
- PHP Parser fails when parsing @rest\property! HOT 1
- PHP 8 error: array and string offset access with curly braces HOT 2
- Default string value with spaces
- parsing error in the example of Swagger documentation HOT 1
- Duplicate properties and parameters are output twice
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 phpswaggergen.