$ref to json schema in same folder not working
I have this snippet from my definitions of my swagger.json document: ... "Partner": { "$ref": "Partner.json" } ... This should work, it works in swagger-ui, but does not seem to work with autorest, I keep getting validation errors. In addition, in another area, I have this snippet ... "additionalItems": false ...
It looks like this is also not supported. Am I correct or am I doing something wrong?
This is not a complete reference:
"Partner": {u
"$ref": "Partner.json"
}
If you are pulling a model from the other file, then use "$ref" : "Partner.json#/definitions/partner"
"additionalItems": false is not permitted in Swagger (OpenAPI2)
Couple follow-up questions, thanks for your information, I have tried several swagger validators, but so far no luck. It seems there are always issues following $ref to external documents. Per documentation at https://swagger.io/docs/specification/using-ref/ ... it looks here like a reference to a document without a further path is acceptable. I also used the json schema validator at https://json-schema-validator.herokuapp.com/index.jsp and it did not report a problem with additionalItems as you mention above. Would really appreciate some advice for a validator that actually provides helpful information.
any resolution on this? I am also running into the same problem.
Below setup is not working for me.
runme.cmd
autorest --input-file=main.yaml --csharp --output-folder=CodeGen --namespace=MultiFile.CodeGen
main.yaml
swagger: '2.0'
info:
version: 0.0.0
title: Simple API
paths:
/foo:
get:
operationId: GetFoo
responses:
'200':
description: OK
/bar:
get:
operationId: GetBar
responses:
'200':
description: OK
schema:
$ref: 'User.yaml#/definitions/User'
/nested:
get:
operationId: GetNested
responses:
'200':
description: OK
schema:
type: object
properties:
name:
type: string
User.yaml
definitions:
User:
type: object
properties:
name:
type: string
What version of autorest are you using?
I just tried this:
C:\tmp\y> autorest --input-file=main.yaml --csharp --output-folder=CodeGen --namespace=MultiFile.CodeGen
AutoRest code generation utility [version: 2.0.4283; node: v10.15.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
Loading AutoRest core 'C:\Users\garretts\.autorest\@[email protected]\node_modules\@microsoft.azure\autorest-core\dist' (2.0.4302)
Loading AutoRest extension '@microsoft.azure/autorest.csharp' (~2.3.79->2.3.82)
Loading AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.55->2.3.55)
C:\tmp\y> dir .\CodeGen\
Directory: C:\tmp\y\CodeGen
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 4/19/2019 11:41 AM Models
-a---- 4/19/2019 11:42 AM 2301 ISimpleAPI.cs
-a---- 4/19/2019 11:42 AM 21079 SimpleAPI.cs
-a---- 4/19/2019 11:42 AM 3260 SimpleAPIExtensions.cs
it does fail with autorest@beta -- probably because we're loading referenced files as swagger, and probably need to loosen it up
we are using autorest@beta for our 3.0 swagger definitions, is there any timeline when will this be fixed?
I can't promise a fix right away, I'm neck-deep right now.
A temporary workaround:
put the swagger,info and paths section into the secondary files
swagger: '2.0'
info:
version: 0.0.0
title: Simple API
paths: {}
definitions:
User:
type: object
properties:
name:
type: string
Thanks for the workaround but that works only for version 2.0 if you change it to openapi 3.0.0 it doesn't work