generate models for definitions that haven't been referenced within paths?
@wing328 I had a quick question - I have a file called bar.json that basically looks like:
{ "swagger": "2.0", "info": { "version": "1.0.0", "title": "xxx", "description": "yyy", "termsOfService": "xxx", "contact": { "name": "xxx" }, "license": { "name": "MIT" } }, "host": "xxx", "basePath": "", "schemes": [ "https" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/foo": { "$ref":"./Foo.json#/thefoo" } } }
and in Foo.json I have:
{ "thefoo": { "get": { "operationId": "getFoo", "produces": [ "application/json" ], "responses": { "200": { "schema": { "$ref": "./Foo.json#FooResponse" } } } } }, "definitions": { "FooResponse" : { "type": "object" }, "OtherStuff": { "type": "object" } } }
Everything gets generated correctly except OtherStuff doesn't get generated - it's not referenced explicitly but I would like to figure out a way to still generate an object for it (because it can be buried within a FooResponse sometimes)...
(btw this happens for Swift + Android but my guess it's an overall thing that is probably by design - but if there is a way to override this behavior that would help - thx)
(one hack could be to just add a new property to fooResponse like this: "xxxCodeGenxxx": { "type": "object", "$ref": "./Foo.json#OtherStuff" }
but this feels gross
(I did end up just referencing everything through definitions in the main file but seems like swagger should look at definitions in other files as well somehow...)
Hi @jaz-ah, that is by design. We only bring in externally-referenced models if they're referenced. In fact, we don't parse the entire remote file--just what you ask for (and any references it may have).
The problem is, many remote files are extremely large (common files) and bringing in everything would be really ugly if you don't need it all.
@fehguy fair enough - thx!