-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model inside a model support in response definition #10
Comments
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. |
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 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! |
This was a pretty simple fix, adding some useful functionality. |
Awesome! Will update and test, and will let you know. |
Confirming the generated docs work as expected in the swagger editor using version 2.3.7. Thanks |
I have the following model definitions:
and later on declaring the response type as follows:
so I'm trying to make a reference of a model inside another model. but when I execute, I get the following exception:
Property format not recognized: 'address'
is model inside a model supported the same way as an array of models?
if the definition is changed as follows, the generation executes successfuly, but does not match the real output of my API
thank you
The text was updated successfully, but these errors were encountered: