com.smartbear.swagger4j
Class Swagger

java.lang.Object
  extended by com.smartbear.swagger4j.Swagger

public class Swagger
extends Object

Utility methods to read/write/create Swagger objects


Method Summary
static ApiDeclaration createApiDeclaration(String basePath, String resourcePath)
          Creates an empty ApiDeclaration with the specified basePath and resourcePath
static SwaggerReader createReader()
          Creates a SwaggerReader using the available SwaggerFactory
static ResourceListing createResourceListing(String basePath)
          Creates an empty ResourceListing with the specified basePath - uses the standard SwaggerFactory
static SwaggerFactory createSwaggerFactory()
          method for creating a SwaggerFactory; uses java.util.ServiceLoader to find a SwaggerFactory implementation - falls back to the default implementation if none are found
static SwaggerWriter createWriter(Constants.Format format)
          Creates a SwaggerWriter for the specified format using the default SwaggerFactory
static ResourceListing readSwagger(URI uri)
          Reads a Swagger definition from the specified URI, uses the default SwaggerReader implementation
static void writeSwagger(ResourceListing resourceListing, String path)
          Writes the specified Swagger ResourceListing to the specified local path in json format.
static void writeSwagger(ResourceListing resourceListing, String path, Constants.Format format)
          Writes the specified Swagger ResourceListing to the specified local path in either json or xml format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createResourceListing

public static ResourceListing createResourceListing(String basePath)
Creates an empty ResourceListing with the specified basePath - uses the standard SwaggerFactory

Parameters:
basePath - the basePath to use for resolving paths to the API Declaration
Returns:
an empty ResourceListing

createApiDeclaration

public static ApiDeclaration createApiDeclaration(String basePath,
                                                  String resourcePath)
Creates an empty ApiDeclaration with the specified basePath and resourcePath

Parameters:
basePath - used to resolve API paths defined in this declaration
resourcePath - path to the actual resource described in the declaration
Returns:
an empty ApiDeclaration

createReader

public static SwaggerReader createReader()
Creates a SwaggerReader using the available SwaggerFactory

Returns:
a SwaggerReader

readSwagger

public static ResourceListing readSwagger(URI uri)
                                   throws IOException
Reads a Swagger definition from the specified URI, uses the default SwaggerReader implementation

Parameters:
uri - the URI of the api-docs document defining the Swagger ResourceListing
Returns:
the initialized ResourceListing object
Throws:
IOException

writeSwagger

public static void writeSwagger(ResourceListing resourceListing,
                                String path)
                         throws IOException
Writes the specified Swagger ResourceListing to the specified local path in json format. Uses the default SwaggerWriter

Parameters:
resourceListing - the resourceListing to write
path - path to an existing folder where the api-docs and api declarations will be written
Throws:
IOException

writeSwagger

public static void writeSwagger(ResourceListing resourceListing,
                                String path,
                                Constants.Format format)
                         throws IOException
Writes the specified Swagger ResourceListing to the specified local path in either json or xml format. Uses the default SwaggerWriter

Parameters:
resourceListing - the resourceListing to write
path - path to an existing folder where the api-docs and api declarations will be written
format - the format to use; either json or xml
Throws:
IOException

createWriter

public static SwaggerWriter createWriter(Constants.Format format)
Creates a SwaggerWriter for the specified format using the default SwaggerFactory

Parameters:
format - the format the writer should use, either json or xml
Returns:
the created SwaggerWriter

createSwaggerFactory

public static SwaggerFactory createSwaggerFactory()
method for creating a SwaggerFactory; uses java.util.ServiceLoader to find a SwaggerFactory implementation - falls back to the default implementation if none are found

Returns:
a SwaggerFactory instance


Copyright © 2013. All Rights Reserved.