Skip to content
This repository has been archived by the owner on Mar 15, 2019. It is now read-only.

RAML 1.0 to Swagger conversion doesn't convert definition type correctly #47

Open
nataliacr opened this issue Jul 19, 2017 · 0 comments

Comments

@nataliacr
Copy link

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant