RAML 1.0 to Swagger conversion doesn't convert definition type correctly
Opened this issue · 0 comments
nataliacr commented
Here is what my RAML 1.0 types array looks like:
[
{
definitions:
dtype:
title: dtype
$ref: '#/definitions/integer'
}
]
When I convert it to swagger type property is being replaced with $ref:
definitions:
dtype:
title: dtype
$ref: '#/definitions/integer'
I found a quick fix for this. In exporters/swagger.js
I included var RAML = require('./baseraml');
and modified _mapSchema
function:
Swagger.prototype._mapSchema = function(schemas) {
return schemas.reduce(function(definitions, schema) {
var definition = {};
if (schema.name) {
definition.title = schema.name;
}
_.merge(definition, RAML.prototype.convertRefFromModel(jsonHelper.parse(schema.Definition)));
mapExample(schema, definition);
definitions[schema.NameSpace] = definition;
return definitions;
}, {});
};
So now when I convert RAML 1.0 to Swagger type property in Definition is being converted as expected:
definitions:
dtype:
title: dtype
type: integer
Is this a good way to fix the issue?