fotinakis/swagger-blocks

Difference in $ref handling when given in nested argument

saverio-kantox opened this issue · 2 comments

I have found that

property :data, type: :array, items: { :'$ref' => :SomethingElse }

does not convert properly the reference into "#/definitions/SomethingElse while

property :data, :'$ref' => :SomethingElse

does.

This forces to use a ugly hack:

property :data, type: :array, items: { :'$ref' => :'#/definitions/SomethingElse' }

Maybe it is due to only handling $ref parameters at the top level of options?

Not sure what's exactly happening there. Can you use the items block syntax we have?

screen shot 2017-09-18 at 9 12 59 am

See the README for more. Feel free to re-open if that doesn't work.

I agree that the block form can be used - but it is inconvenient if the swagger_* are used by other higher level DSLs, where one may want to send a bunch of parameters as arguments.

In my specific use case, I have a swagger_jsonapi_resource DSL method that takes a bunch of attributes and calls the base swagger-blocks API to create the resource.

In all cases, the documentation at https://github.com/fotinakis/swagger-blocks#inline-keys tells that any key can be passed as parameter, without any specific case for the $ref key. If this key has to be treated in a special way, it should be stated in the documentation at the very least.

I will not reopen the issue, but other people might find the context and explanation useful.

Thank you for the amazing library in any case.