user3345282
user3345282

Reputation: 43

Swagger2.0 to RAML conversion

I want to convert given Swagger 2.0 file to RAML.

I used swagger2raml provided in https://github.com/8x8Cloud/swagger2raml which is not converting it. I also checked RESTLET but i don't know which API's to use.

Can someone please help on this? I need a Java based solution.

Upvotes: 3

Views: 617

Answers (2)

Thierry Boileau
Thierry Boileau

Reputation: 866

you can get the Restlet Framework version 2.3.3, and use the following code. You will need:

  • the org.restlet core module
  • the org.restlet.ext.apispark extension and its dependencies

    import org.raml.emitter.RamlEmitter;
    import org.raml.model.Raml;
    import org.restlet.ext.apispark.internal.conversion.TranslationException;
    import org.restlet.ext.apispark.internal.conversion.raml.RamlTranslator;
    import org.restlet.ext.apispark.internal.conversion.swagger.v2_0.SwaggerUtils;
    import org.restlet.ext.apispark.internal.model.Definition;
    public class TestConversion {
        public static void main(String[] args) throws TranslationException {
            Definition definition = SwaggerUtils.getDefinition(
                "/tmp/refImpl.swagger", null, null);
            Raml raml = RamlTranslator.getRaml(definition);
            RamlEmitter re = new RamlEmitter();
            System.out.println(re.dump(raml));
        }
    }
    

Upvotes: 3

Nelson G.
Nelson G.

Reputation: 5441

Try http://studio.restlet.com, it can converts between swagger 2.0, swagger 1.2 and RAML.

Upvotes: 2

Related Questions