GithubHelp home page GithubHelp logo

thomaslprr / xml2swagger Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 2.3 MB

Convert XML files to OpenAPI 2.0 (Swagger 2.0) Json documentation.

Java 100.00%
json xml xml-parser swagger2 swagger swagger-ui parser openapi

xml2swagger's Introduction

GitHub all releases

This project allows you to convert an XML file into OpenAPI 2.0 (Swagger 2.0) documentation in JSON format.

The module also contains all the implementation of the Swagger model in Java class.

You can thus :

  • convert an XML file into Swagger Java objects
  • convert XML file to Swagger Json Documentation
  • convert Swagger Java objects to Swagger Json Documentation

You can find a very detailed documentation here.

Usage

There are two ways to use the module depending on your needs.

In any case, you will need to download the ".jar" file: swagger2xml.jar

Use the module via the command prompt:

To do this you must:

  • Place yourself in the directory of the ".jar" file downloaded above
  • Type the command

java -jar xml2swagger.jar -f <file-name.xml>

for example java -jar xml2swagger.jar -f desktop/perso/example1.xml

-------------or-------------

java -jar xml2swagger.jar -s "<xml-string>"

for example java -jar xml2swagger.jar -s "<global> <rest>...</rest> </global>"

Note:

-s option allows to specify an xml string -s means string input

-f option allows to specify an .xml file address -f means file input

Use the module in the Java source code:

You can also use the module directly in the code.

To do so, you just have to import the .jar file downloaded above in the buildpath of your project.

Then you will benefit from four methods :

Method Description
XmlParser.xmlFileToSwaggerJson(File file); Convert xml file into swagger Json
XmlParser.xmlStringToSwaggerJson(String xml); Convert xml string into swagger Json
XmlParser.xmlFileToJavaClass(File file) Convert xml file into Java class
XmlParser.xmlStringToJavaClass(String xml) Convert xml string into Java class
XmlParser.javaClassToSwaggerJson(Global globalObject) Convert a Global object into a swagger json documentation

The Java class conversion methods are there to increase the development possibilities for people using the module and to offer export methods in YAML instead of Json or the generation of PDF, HTML, etc.

Dependancies

JAXB (Java Architecture for XML Binding)

Version: 2.1

Allows you to transform the XML structure into a Java class

JSON Library

Version: 20210307

JSON Library is an open source Java library for serializing and deserializing Java objects in JSON

Module operation

The module takes an XML file as input which it will convert into Java classes (thanks to JAXB). Once the Java classes have been obtained, the module will create the json swagger 2.0 using the JSON library. The module will return the JSON code.

Java structure

xml2swagger's People

Contributors

thomaslprr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.