Generating an XML Schema from a Swagger File

You can generate an XML schema from a Swagger 1.0, 2.0, and 3.0 file using the menu options without creating a service.

Note: This option is enabled only when the JSON file is any of the Swagger 1.0 file, Swagger 2.0 file, Swagger 3.0 file, and has Swagger Definition.

For Swagger files that do not contain Swagger definition, the Generate XSD Schema menu option is disabled.

Prerequisites

A Swagger 2.0 or a Swagger 3.0 file should exist in the Service Descriptors folder of the project. If not, then import the Swagger file into the Service Descriptors folder before you follow the steps to create its XML schema.

Procedure

  1. Right-click the JSON file in the Service Descriptors folder in your project and select Refactor > Generate XSD Schema.
    A .xsd file gets created in the Schemas folder of your project.
  2. Save the project.
    Note:
    • To figure out which XML schema is related to the Swagger file, right-click the Swagger file and select Refactor -> Open XSD Schema.
    • If you have multiple Swagger files all of which contain a definition for the same object, the definition for the object in all the Swagger files must be identical.
    • If you have multiple Swagger files with one file (a master file) containing a super set of definitions contained in the other files, generate an XSD file from the master Swagger file that contains the super set, and create links to the other files in the master Swagger file. If you create a link to the super set file in one of the subset files and then create an XSD from the subset file, then the XSD will contain only those elements that are common to both files. It will not contain elements for definitions that exist only in the super set file.