Giter Site home page Giter Site logo

swagger-api / swagger-codegen Goto Github PK

View Code? Open in Web Editor NEW
16.5K 415.0 6.0K 102.77 MB

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.

Home Page: http://swagger.io

License: Apache License 2.0

Shell 5.06% Java 37.78% HTML 0.10% Scala 0.26% ActionScript 0.25% CSS 0.06% JavaScript 0.09% Ruby 0.29% Batchfile 0.56% PHP 0.15% TypeScript 1.34% Apex 0.32% PowerShell 0.01% Rust 0.01% C# 0.31% Perl 0.02% Dockerfile 0.02% Mustache 53.39%
swagger swagger-codegen rest rest-api openapi-specification openapi3 open-source swagger-oss

swagger-codegen's Introduction

Build Status

Build Status

Build Status

  • Master (2.4.40-SNAPSHOT): Java Test Windows Test

  • 3.0.52-SNAPSHOT: Java Test Windows Test

Maven Central

⭐⭐⭐ If you would like to contribute, please refer to guidelines and a list of open tasks.:star::star::star:

📔 For more information, please refer to the Wiki page and FAQ 📔

⚠️ If the OpenAPI/Swagger spec is obtained from an untrusted source, please make sure you've reviewed the spec before using Swagger Codegen to generate the API client, server stub or documentation as code injection may occur ⚠️

🚀 ProductHunt: https://producthunt.com/posts/swagger-codegen 🚀

📔 The eBook A Beginner's Guide to Code Generation for REST APIs is a good starting point for beginners.

Versioning

NOTE: version 2.X (io.swagger) and 3.X (io.swagger.codegen.v3) have different group ids.

2.X and 3.X version lines of Swagger Codegen are available; 2.X (master branch) supports Swagger/OpenAPI version 2, while 3.X (3.0.0 branch) supports OpenAPI version 3 (and version 2 via spec conversion to version 3). Online generator of version 3.X supports both generation from Swagger/OpenAPI version 2 (by using engine + generators of 2.X) and version 3 specifications.

NOTE: this document refers to version 2.X, check here for 3.X.

Swagger Codegen 2.X (master branch)

Swagger Codegen 2.X supports Swagger/OpenAPI version 2.

group id: io.swagger maven central (maven plugin): https://mvnrepository.com/artifact/io.swagger/swagger-codegen-maven-plugin

dependency example:

<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.4.39</version>
</dependency>

Swagger Codegen 3.X (3.0.0 branch)

Swagger Codegen 3.X supports OpenAPI version 3 (and version 2 via spec conversion to version 3) Online generator of version 3.X supports both generation from Swagger/OpenAPI version 2 (by using engine + generators of 2.X) and version 3 specifications.

group id: io.swagger.codegen.v3 maven central: https://mvnrepository.com/artifact/io.swagger.codegen.v3

dependency example:

<dependency>
    <groupId>io.swagger.codegen.v3</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>3.0.52</version>
</dependency>

Overview

This is the Swagger Codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an OpenAPI Spec. Currently, the following languages/frameworks are supported:

  • API clients: ActionScript, Ada, Apex, Bash, C# (.net 2.0, 3.5 or later), C++ (cpprest, Qt5, Tizen), Clojure, Dart, Elixir, Elm, Eiffel, Erlang, Go, Groovy, Haskell (http-client, Servant), Java (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured), Kotlin, Lua, Node.js (ES5, ES6, AngularJS with Google Closure Compiler annotations) Objective-C, Perl, PHP, PowerShell, Python, R, Ruby, Rust (rust, rust-server), Scala (akka, http4s, swagger-async-httpclient), Swift (2.x, 3.x, 4.x, 5.x), Typescript (Angular1.x, Angular2.x, Fetch, jQuery, Node)
  • Server stubs: Ada, C# (ASP.NET Core, NancyFx), C++ (Pistache, Restbed), Erlang, Go, Haskell (Servant), Java (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, PKMST), Kotlin, PHP (Lumen, Slim, Silex, Symfony, Zend Expressive), Python (Flask), NodeJS, Ruby (Sinatra, Rails5), Rust (rust-server), Scala (Finch, Lagom, Scalatra)
  • API documentation generators: HTML, Confluence Wiki
  • Configuration files: Apache2
  • Others: JMeter

Check out OpenAPI-Spec for additional information about the OpenAPI project.

Table of contents

Compatibility

The OpenAPI Specification has undergone 3 revisions since initial creation in 2010. The Swagger Codegen project has the following compatibilities with the OpenAPI Specification:

Swagger Codegen Version Release Date OpenAPI Spec compatibility Notes
3.0.53-SNAPSHOT (current 3.0.0, upcoming minor release) SNAPSHOT TBD 1.0, 1.1, 1.2, 2.0, 3.0 Minor release
3.0.52 (current stable) 2023-12-30 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.52
3.0.51 2023-11-21 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.51
3.0.50 2023-10-26 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.50
3.0.49 2023-10-23 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.49
3.0.48 2023-10-19 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.48
3.0.47 2023-10-02 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.47
3.0.46 2023-06-07 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.46
3.0.45 2023-06-02 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.45
3.0.44 2023-05-23 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.44
3.0.43 2023-05-17 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.43
3.0.42 2023-04-05 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.42
3.0.41 2023-02-16 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.41
3.0.40 2023-01-27 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.40
3.0.39 2023-01-25 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.39
3.0.38 2023-01-22 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.38
3.0.37 2023-01-19 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.37
3.0.36 2022-11-10 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.36
3.0.35 2022-08-15 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.35
3.0.34 2022-04-12 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.34
3.0.33 2022-02-07 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.33
3.0.32 2022-01-11 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.32
3.0.31 2021-12-28 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.31
3.0.30 2021-11-18 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.30
3.0.29 2021-10-05 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.29
3.0.28 2021-09-30 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.28
3.0.27 2021-06-28 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.27
3.0.26 2021-05-28 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.26
3.0.25 2021-03-04 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.25
3.0.24 2020-12-29 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.24
3.0.23 2020-11-02 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.23
3.0.22 2020-10-05 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.22
3.0.21 2020-07-28 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.21
3.0.20 2020-05-18 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.20
3.0.19 2020-04-02 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.19
3.0.18 2020-02-26 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.18
3.0.17 2020-02-23 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.17
3.0.17 2020-01-15 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.16
3.0.15 2020-01-03 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.15
3.0.14 2019-11-16 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.14
3.0.13 2019-10-16 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.13
3.0.12 2019-10-14 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.12
3.0.11 2019-08-24 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.11
3.0.10 2019-07-11 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.10
3.0.9 2019-06-28 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.9
3.0.8 2019-04-25 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.8
3.0.7 2019-03-26 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.7
3.0.5 2019-02-18 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.5
3.0.4 2019-01-16 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.4
3.0.3 2018-11-30 1.0, 1.1, 1.2, 2.0, 3.0 tag v3.0.3
3.0.2 2018-10-19 1.0, 1.1, 1.2, 2.0, 3.0 Minor release
3.0.1 2018-10-05 1.0, 1.1, 1.2, 2.0, 3.0 Major release with breaking changes
3.0.0 2018-09-06 1.0, 1.1, 1.2, 2.0, 3.0 Major release with breaking changes
2.4.40-SNAPSHOT (current master, upcoming minor release) SNAPSHOT TBD 1.0, 1.1, 1.2, 2.0 Minor release
2.4.39 (current stable) 2024-01-02 1.0, 1.1, 1.2, 2.0 tag v2.4.39
2.4.38 2023-12-29 1.0, 1.1, 1.2, 2.0 tag v2.4.38
2.4.37 2023-11-21 1.0, 1.1, 1.2, 2.0 tag v2.4.37
2.4.36 2023-10-26 1.0, 1.1, 1.2, 2.0 tag v2.4.36
2.4.35 2023-10-26 1.0, 1.1, 1.2, 2.0 tag v2.4.35
2.4.34 2023-10-19 1.0, 1.1, 1.2, 2.0 tag v2.4.34
2.4.33 2023-10-02 1.0, 1.1, 1.2, 2.0 tag v2.4.33
2.4.32 2023-05-17 1.0, 1.1, 1.2, 2.0 tag v2.4.32
2.4.31 2023-04-02 1.0, 1.1, 1.2, 2.0 tag v2.4.31
2.4.30 2023-02-16 1.0, 1.1, 1.2, 2.0 tag v2.4.30
2.4.29 2022-11-10 1.0, 1.1, 1.2, 2.0 tag v2.4.29
2.4.28 2022-08-15 1.0, 1.1, 1.2, 2.0 tag v2.4.28
2.4.27 2022-04-12 1.0, 1.1, 1.2, 2.0 tag v2.4.27
2.4.26 2022-02-07 1.0, 1.1, 1.2, 2.0 tag v2.4.26
2.4.25 2021-12-28 1.0, 1.1, 1.2, 2.0 tag v2.4.25
2.4.24 2021-11-18 1.0, 1.1, 1.2, 2.0 tag v2.4.24
2.4.23 2021-10-08 1.0, 1.1, 1.2, 2.0 tag v2.4.23
2.4.22 2021-09-30 1.0, 1.1, 1.2, 2.0 tag v2.4.22
2.4.21 2021-06-28 1.0, 1.1, 1.2, 2.0 tag v2.4.21
2.4.20 2021-05-28 1.0, 1.1, 1.2, 2.0 tag v2.4.20
2.4.19 2021-03-04 1.0, 1.1, 1.2, 2.0 tag v2.4.19
2.4.18 2020-12-29 1.0, 1.1, 1.2, 2.0 tag v2.4.18
2.4.17 2020-11-02 1.0, 1.1, 1.2, 2.0 tag v2.4.17
2.4.16 2020-10-05 1.0, 1.1, 1.2, 2.0 tag v2.4.16
2.4.15 2020-07-28 1.0, 1.1, 1.2, 2.0 tag v2.4.15
2.4.14 2020-05-18 1.0, 1.1, 1.2, 2.0 tag v2.4.14
2.4.13 2020-04-02 1.0, 1.1, 1.2, 2.0 tag v2.4.13
2.4.12 2020-01-15 1.0, 1.1, 1.2, 2.0 tag v2.4.12
2.4.11 2020-01-03 1.0, 1.1, 1.2, 2.0 tag v2.4.11
2.4.10 2019-11-16 1.0, 1.1, 1.2, 2.0 tag v2.4.10
2.4.9 2019-10-14 1.0, 1.1, 1.2, 2.0 tag v2.4.9
2.4.8 2019-08-24 1.0, 1.1, 1.2, 2.0 tag v2.4.8
2.4.7 2019-07-11 1.0, 1.1, 1.2, 2.0 tag v2.4.7
2.4.6 2019-06-28 1.0, 1.1, 1.2, 2.0 tag v2.4.6
2.4.5 2019-04-25 1.0, 1.1, 1.2, 2.0 tag v2.4.5
2.4.4 2019-03-26 1.0, 1.1, 1.2, 2.0 tag v2.4.4
2.4.2 2019-02-18 1.0, 1.1, 1.2, 2.0 tag v2.4.2
2.4.1 2019-01-16 1.0, 1.1, 1.2, 2.0 tag v2.4.1
2.4.0 2018-11-30 1.0, 1.1, 1.2, 2.0 tag v2.4.0
2.3.1 2018-01-17 1.0, 1.1, 1.2, 2.0 tag v2.3.1
2.3.0 2017-12-21 1.0, 1.1, 1.2, 2.0 tag v2.3.0
2.2.3 2017-07-15 1.0, 1.1, 1.2, 2.0 tag v2.2.3
2.2.2 2017-03-01 1.0, 1.1, 1.2, 2.0 tag v2.2.2
2.2.1 2016-08-07 1.0, 1.1, 1.2, 2.0 tag v2.2.1
2.1.6 2016-04-06 1.0, 1.1, 1.2, 2.0 tag v2.1.6
2.0.17 2014-08-22 1.1, 1.2 tag v2.0.17
1.0.4 2012-04-12 1.0, 1.1 tag v1.0.4

Prerequisites

If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):

# Download current stable 2.x.x branch (Swagger and OpenAPI version 2)
wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.39/swagger-codegen-cli-2.4.39.jar -O swagger-codegen-cli.jar

java -jar swagger-codegen-cli.jar help

# Download current stable 3.x.x branch (OpenAPI version 3)
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.52/swagger-codegen-cli-3.0.52.jar -O swagger-codegen-cli.jar

java -jar swagger-codegen-cli.jar --help

For Windows users, you will need to install wget or you can use Invoke-WebRequest in PowerShell (3.0+), e.g. Invoke-WebRequest -OutFile swagger-codegen-cli.jar https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.39/swagger-codegen-cli-2.4.39.jar

On a mac, it's even easier with brew:

brew install swagger-codegen

To build from source, you need the following installed and available in your $PATH:

OS X Users

Don't forget to install Java 11+.

Export JAVA_HOME in order to use the supported Java version:

export JAVA_HOME=`/usr/libexec/java_home -v 11`
export PATH=${JAVA_HOME}/bin:$PATH

Building

After cloning the project, you can build it from source with this command:

mvn clean package

If you don't have maven installed, you may directly use the included maven wrapper, and build with the command:

./mvnw clean package

Homebrew

To install, run brew install swagger-codegen

Here is an example usage:

swagger-codegen generate -i https://petstore.swagger.io/v2/swagger.json -l ruby -o /tmp/test/

Docker

Development in docker

You can use run-in-docker.sh to do all development. This script maps your local repository to /gen in the docker container. It also maps ~/.m2/repository to the appropriate container location.

To execute mvn package:

git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
./run-in-docker.sh mvn package

Build artifacts are now accessible in your working directory.

Once built, run-in-docker.sh will act as an executable for swagger-codegen-cli. To generate code, you'll need to output to a directory under /gen (e.g. /gen/out). For example:

./run-in-docker.sh help # Executes 'help' command for swagger-codegen-cli
./run-in-docker.sh langs # Executes 'langs' command for swagger-codegen-cli
./run-in-docker.sh /gen/bin/go-petstore.sh  # Builds the Go client
./run-in-docker.sh generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml \
    -l go -o /gen/out/go-petstore -DpackageName=petstore # generates go client, outputs locally to ./out/go-petstore

Standalone generator Development in docker

See standalone generator development

Run Docker in Vagrant

Prerequisite: install Vagrant and VirtualBox.

git clone http://github.com/swagger-api/swagger-codegen.git
cd swagger-codegen
vagrant up
vagrant ssh
cd /vagrant
./run-in-docker.sh mvn package

Public Pre-built Docker images

Swagger Generator Docker Image

The Swagger Generator image can act as a self-hosted web application and API for generating code. This container can be incorporated into a CI pipeline, and requires at least two HTTP requests and some docker orchestration to access generated code.

Example usage (note this assumes jq is installed for command line processing of JSON):

# Start container and save the container id
CID=$(docker run -d swaggerapi/swagger-generator)
# allow for startup
sleep 5
# Get the IP of the running container
GEN_IP=$(docker inspect --format '{{.NetworkSettings.IPAddress}}'  $CID)
# Execute an HTTP request and store the download link
RESULT=$(curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
  "swaggerUrl": "https://petstore.swagger.io/v2/swagger.json"
}' 'http://localhost:8188/api/gen/clients/javascript' | jq '.link' | tr -d '"')
# Download the generated zip and redirect to a file
curl $RESULT > result.zip
# Shutdown the swagger generator image
docker stop $CID && docker rm $CID

In the example above, result.zip will contain the generated client.

Swagger Codegen CLI Docker Image

The Swagger Codegen image acts as a standalone executable. It can be used as an alternative to installing via homebrew, or for developers who are unable to install Java or upgrade the installed version.

To generate code with this image, you'll need to mount a local location as a volume.

Example:

docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate \
    -i https://petstore.swagger.io/v2/swagger.json \
    -l go \
    -o /local/out/go

(On Windows replace ${PWD} with %CD%)

The generated code will be located under ./out/go in the current directory.

Getting Started

To generate a PHP client for https://petstore.swagger.io/v2/swagger.json, please run the following

git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
mvn clean package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
   -i https://petstore.swagger.io/v2/swagger.json \
   -l php \
   -o /var/tmp/php_api_client

(if you're on Windows, replace the last command with java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i https://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client)

You can also download the JAR (latest release) directly from maven.org

To get a list of general options available, please run java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate (for version 3.x check 3.0.0 branch)

To get a list of PHP specified options (which can be passed to the generator with a config file via the -c option), please run java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l php

Generators

To generate a sample client library

You can build a client against the swagger sample petstore API as follows:

./bin/java-petstore.sh

(On Windows, run .\bin\windows\java-petstore.bat instead)

This will run the generator with this command:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
  -i https://petstore.swagger.io/v2/swagger.json \
  -l java \
  -o samples/client/petstore/java

with a number of options. You can get the options with the help generate command (below only shows partial results):

NAME
        swagger-codegen-cli generate - Generate code with chosen lang

SYNOPSIS
        swagger-codegen-cli generate
                [(-a <authorization> | --auth <authorization>)]
                [--additional-properties <additional properties>...]
                [--api-package <api package>] [--artifact-id <artifact id>]
                [--artifact-version <artifact version>]
                [(-c <configuration file> | --config <configuration file>)]
                [-D <system properties>...] [--git-repo-id <git repo id>]
                [--git-user-id <git user id>] [--group-id <group id>]
                [--http-user-agent <http user agent>]
                (-i <spec file> | --input-spec <spec file>)
                [--ignore-file-override <ignore file override location>]
                [--import-mappings <import mappings>...]
                [--instantiation-types <instantiation types>...]
                [--invoker-package <invoker package>]
                (-l <language> | --lang <language>)
                [--language-specific-primitives <language specific primitives>...]
                [--library <library>] [--model-name-prefix <model name prefix>]
                [--model-name-suffix <model name suffix>]
                [--model-package <model package>]
                [(-o <output directory> | --output <output directory>)]
                [--release-note <release note>] [--remove-operation-id-prefix]
                [--reserved-words-mappings <reserved word mappings>...]
                [(-s | --skip-overwrite)]
                [(-t <template directory> | --template-dir <template directory>)]
                [--type-mappings <type mappings>...] [(-v | --verbose)]

OPTIONS
        -a <authorization>, --auth <authorization>
            adds authorization headers when fetching the swagger definitions
            remotely. Pass in a URL-encoded string of name:header with a comma
            separating multiple values

...... (results omitted)

        -v, --verbose
            verbose mode

You can then compile and run the client, as well as unit tests against it:

cd samples/client/petstore/java
mvn package

Other languages have petstore samples, too:

./bin/android-petstore.sh
./bin/java-petstore.sh
./bin/objc-petstore.sh

Generating libraries from your server

It's just as easy--just use the -i flag to point to either a server or file.

Modifying the client library format

Don't like the default swagger client syntax? Want a different language supported? No problem! Swagger Codegen processes mustache templates with the jmustache engine. You can modify our templates or make your own.

You can look at modules/swagger-codegen/src/main/resources/${your-language} for examples. To make your own templates, create your own files and use the -t flag to specify your template folder. It actually is that easy.

Making your own codegen modules

If you're starting a project with a new language and don't see what you need, Swagger Codegen can help you create a project to generate your own libraries:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar meta \
  -o output/myLibrary -n myClientCodegen -p com.my.company.codegen

This will write, in the folder output/myLibrary, all the files you need to get started, including a `README.md. Once modified and compiled, you can load your library with the codegen and generate clients with your own, custom-rolled logic.

You would then compile your library in the output/myLibrary folder with mvn package and execute the codegen like such:

java -cp output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen

For Windows users, you will need to use ; instead of : in the classpath, e.g.

java -cp output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar;modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen

Note the myClientCodegen is an option now, and you can use the usual arguments for generating your library:

java -cp output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
  io.swagger.codegen.SwaggerCodegen generate -l myClientCodegen\
  -i https://petstore.swagger.io/v2/swagger.json \
  -o myClient

See also standalone generator development

Where is Javascript???

See our javascript library--it's completely dynamic and doesn't require static code generation. There is a third-party component called swagger-js-codegen that can generate angularjs or nodejs source code from an OpenAPI Specification.

❗ On Dec 7th 2015, a Javascript API client generator has been added by @jfiala.

Generating a client from local files

If you don't want to call your server, you can save the OpenAPI Spec files into a directory and pass an argument to the code generator like this:

-i ./modules/swagger-codegen/src/test/resources/2_0/petstore.json

Great for creating libraries on your ci server, from the Swagger Editor... or while coding on an airplane.

Selective generation

You may not want to generate all models in your project. Likewise you may want just one or two apis to be written. If that's the case, you can use system properties to control the output:

The default is generate everything supported by the specific library. Once you enable a feature, it will restrict the contents generated:

# generate only models
java -Dmodels {opts}

# generate only apis
java -Dapis {opts}

# generate only supporting files
java -DsupportingFiles

# generate models and supporting files
java -Dmodels -DsupportingFiles

To control the specific files being generated, you can pass a CSV list of what you want:

# generate the User and Pet models only
-Dmodels=User,Pet

# generate the User model and the supportingFile `StringUtil.java`:
-Dmodels=User -DsupportingFiles=StringUtil.java

To control generation of docs and tests for api and models, pass false to the option. For api, these options are -DapiTests=false and -DapiDocs=false. For models, -DmodelTests=false and -DmodelDocs=false. These options default to true and don't limit the generation of the feature options listed above (like -Dapi):

# generate only models (with tests and documentation)
java -Dmodels {opts}

# generate only models (with tests but no documentation)
java -Dmodels -DmodelDocs=false {opts}

# generate only User and Pet models (no tests and no documentation)
java -Dmodels=User,Pet -DmodelTests=false {opts}

# generate only apis (without tests)
java -Dapis -DapiTests=false {opts}

# generate only apis (modelTests option is ignored)
java -Dapis -DmodelTests=false {opts}

When using selective generation, only the templates needed for the specific generation will be used.

Ignore file format

Swagger Codegen supports a .swagger-codegen-ignore file, similar to .gitignore or .dockerignore you're probably already familiar with.

The ignore file allows for better control over overwriting existing files than the --skip-overwrite flag. With the ignore file, you can specify individual files or directories can be ignored. This can be useful, for example if you only want a subset of the generated code.

Examples:

# Swagger Codegen Ignore
# Lines beginning with a # are comments

# This should match build.sh located anywhere.
build.sh

# Matches build.sh in the root
/build.sh

# Exclude all recursively
docs/**

# Explicitly allow files excluded by other rules
!docs/UserApi.md

# Recursively exclude directories named Api
# You can't negate files below this directory.
src/**/Api/

# When this file is nested under /Api (excluded above),
# this rule is ignored because parent directory is excluded by previous rule.
!src/**/PetApiTests.cs

# Exclude a single, nested file explicitly
src/IO.Swagger.Test/Model/AnimalFarmTests.cs

The .swagger-codegen-ignore file must exist in the root of the output directory.

Upon first code generation, you may also pass the CLI option --ignore-file-override=/path/to/ignore_file for greater control over generated outputs. Note that this is a complete override, and will override the .swagger-codegen-ignore file in an output directory when regenerating code.

Editor support for .swagger-codegen-ignore files is available in IntelliJ via the .ignore plugin.

Customizing the generator

There are different aspects of customizing the code generator beyond just creating or modifying templates. Each language has a supporting configuration file to handle different type mappings, etc:

$ ls -1 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/
AbstractJavaJAXRSServerCodegen.java
AbstractTypeScriptClientCodegen.java
... (results omitted)
TypeScriptAngularClientCodegen.java
TypeScriptNodeClientCodegen.java

Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc. you can use a json config file to pass the values.

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
  -i https://petstore.swagger.io/v2/swagger.json \
  -l java \
  -o samples/client/petstore/java \
  -c path/to/config.json

and config.json contains the following as an example:

{
  "apiPackage" : "petstore"
}

Supported config options can be different per language. Running config-help -l {lang} will show available options. These options are applied via configuration file (e.g. config.json) or by passing them with java -jar swagger-codegen-cli.jar -D{optionName}={optionValue}. (If -D{optionName} does not work, please open a ticket and we'll look into it)

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l java

Output

CONFIG OPTIONS
	modelPackage
	    package for generated models

	apiPackage
	    package for generated api classes
...... (results omitted)
	library
	    library template (sub-template) to use:
	    jersey1 - HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2
	    jersey2 - HTTP client: Jersey client 2.6
	    feign - HTTP client: Netflix Feign 8.1.1.  JSON processing: Jackson 2.6.3
	    okhttp-gson (default) - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1
	    retrofit - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)
        retrofit2 - HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2)
        google-api-client - HTTP client: google-api-client 1.23.0. JSON processing: Jackson 2.8.9
        rest-assured - HTTP client: rest-assured : 3.1.0. JSON processing: Gson 2.6.1. Only for Java8

Your config file for Java can look like

{
  "groupId": "com.my.company",
  "artifactId": "MyClient",
  "artifactVersion": "1.2.0",
  "library": "feign"
}

For all the unspecified options default values will be used.

Another way to override default options is to extend the config class for the specific language. To change, for example, the prefix for the Objective-C generated files, simply subclass the ObjcClientCodegen.java:

package com.mycompany.swagger.codegen;

import io.swagger.codegen.languages.*;

public class MyObjcCodegen extends ObjcClientCodegen {
    static {
        PREFIX = "HELO";
    }
}

and specify the classname when running the generator:

-l com.mycompany.swagger.codegen.MyObjcCodegen

Your subclass will now be loaded and overrides the PREFIX value in the superclass.

Bringing your own models

Sometimes you don't want a model generated. In this case, you can simply specify an import mapping to tell the codegen what not to create. When doing this, every location that references a specific model will refer back to your classes. Note, this may not apply to all languages...

To specify an import mapping, use the --import-mappings argument and specify the model-to-import logic as such:

--import-mappings Pet=my.models.MyPet

Or for multiple mappings:

--import-mappings Pet=my.models.MyPet,Order=my.models.MyOrder

or

--import-mappings Pet=my.models.MyPet --import-mappings Order=my.models.MyOrder

Validating your OpenAPI Spec

You have options. The easiest is to use our online validator which not only will let you validate your spec, but with the debug flag, you can see what's wrong with your spec. For example:

http://online.swagger.io/validator/debug?url=https://petstore.swagger.io/v2/swagger.json

Generating dynamic html api documentation

To do so, just use the -l dynamic-html flag when reading a spec file. This creates HTML documentation that is available as a single-page application with AJAX. To view the documentation:

cd samples/dynamic-html/
npm install
node .

Which launches a node.js server so the AJAX calls have a place to go.

Generating static html api documentation

To do so, just use the -l html flag when reading a spec file. This creates a single, simple HTML file with embedded css so you can ship it as an email attachment, or load it from your filesystem:

cd samples/html/
open index.html

To build a server stub

Please refer to https://github.com/swagger-api/swagger-codegen/wiki/Server-stub-generator-HOWTO for more information.

To build the codegen library

This will create the Swagger Codegen library from source.

mvn package

Note! The templates are included in the library generated. If you want to modify the templates, you'll need to either repackage the library OR specify a path to your scripts

Workflow Integration

Maven Integration

You can use the swagger-codegen-maven-plugin for integrating with your workflow, and generating any codegen target.

Gradle Integration

Gradle Swagger Generator Plugin is available for generating source code and API document.

GitHub Integration

To push the auto-generated SDK to GitHub, we provide git_push.sh to streamline the process. For example:

  1. Create a new repository in GitHub (Ref: https://help.github.com/articles/creating-a-new-repository/)

  2. Generate the SDK

 java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l perl \
 --git-user-id "swaggerapi" \
 --git-repo-id "petstore-perl" \
 --release-note "Github integration demo" \
 -o /var/tmp/perl/petstore
  1. Push the SDK to GitHub
cd /var/tmp/perl/petstore
/bin/sh ./git_push.sh

Online generators

One can also generate API client or server using the online generators (https://generator.swagger.io)

For example, to generate Ruby API client, simply send the following HTTP request using curl:

curl -X POST -H "content-type:application/json" -d '{"swaggerUrl":"https://petstore.swagger.io/v2/swagger.json"}' https://generator.swagger.io/api/gen/clients/ruby

Then you will receive a JSON response with the URL to download the zipped code.

To customize the SDK, you can POST to https://generator.swagger.io/api/gen/clients/{language} with the following HTTP body:

{
  "options":  {},
  "swaggerUrl": "https://petstore.swagger.io/v2/swagger.json"
}

in which the options for a language can be obtained by submitting a GET request to https://generator.swagger.io/api/gen/clients/{language}:

For example, curl https://generator.swagger.io/api/gen/clients/python returns

{
  "packageName": {
    "opt": "packageName",
    "description": "python package name (convention: snake_case).",
    "type": "string",
    "default": "swagger_client"
  },
  "packageVersion": {
    "opt": "packageVersion",
    "description": "python package version.",
    "type": "string",
    "default": "1.0.0"
  },
  "sortParamsByRequiredFlag": {
    "opt": "sortParamsByRequiredFlag",
    "description": "Sort method arguments to place required parameters before optional parameters.",
    "type": "boolean",
    "default": "true"
  }
}

To set package name to pet_store, the HTTP body of the request is as follows:

{
  "options": {
    "packageName": "pet_store"
  },
  "swaggerUrl": "https://petstore.swagger.io/v2/swagger.json"
}

and here is the curl command:

curl -H "Content-type: application/json" -X POST -d '{"options": {"packageName": "pet_store"},"swaggerUrl": "https://petstore.swagger.io/v2/swagger.json"}' https://generator.swagger.io/api/gen/clients/python

Instead of using swaggerUrl with an URL to the OpenAPI/Swagger spec, one can include the spec in the JSON payload with spec, e.g.

{
  "options": {},
  "spec": {
    "swagger": "2.0",
    "info": {
      "version": "1.0.0",
      "title": "Test API"
    },
    ...
  }
}

Guidelines for Contribution

Please refer to this page

Companies/Projects using Swagger Codegen

Here are some companies/projects using Swagger Codegen in production. To add your company/project to the list, please visit README.md and click on the icon to edit the page.

Presentations/Videos/Tutorials/Books

Swagger Codegen Core Team

Swagger Codegen core team members are contributors who have been making significant contributions (review issues, fix bugs, make enhancements, etc) to the project on a regular basis.

Core Team Members

Template Creator

Here is a list of template creators:

  • API Clients:
    • Ada: @stcarrez
    • Akka-Scala: @cchafer
    • Apex: @asnelling
    • Bash: @bkryza
    • C++ REST: @Danielku15
    • C# (.NET 2.0): @who
    • C# (.NET Standard 1.3 ): @Gronsak
    • C# (.NET 4.5 refactored): @jimschubert
    • Clojure: @xhh
    • Dart: @yissachar
    • Dart (refactored in 2.4.0): @joernahrens
    • Elixir: @niku
    • Elm: @trenneman
    • Eiffel: @jvelilla
    • Erlang: @tsloughter
    • Groovy: @victorgit
    • Go: @wing328
    • Go (rewritten in 2.3.0): @antihax
    • Haskell (http-client): @jonschoning
    • Java (Feign): @davidkiss
    • Java (Retrofit): @0legg
    • Java (Retrofit2): @emilianobonassi
    • Java (Jersey2): @xhh
    • Java (okhttp-gson): @xhh
    • Java (RestTemplate): @nbruno
    • Java (RESTEasy): @gayathrigs
    • Java (Vertx): @lopesmcc
    • Java (Google APIs Client Library): @charlescapps
    • Java (Rest-assured): @viclovsky
    • Javascript/NodeJS: @jfiala
    • Javascript (Closure-annotated Angular) @achew22
    • JMeter: @davidkiss
    • Kotlin: @jimschubert
    • Lua: @daurnimator
    • Perl: @wing328
    • PHP (Guzzle): @baartosz
    • PowerShell: @beatcracker
    • R: @ramnov
    • Rust: @farcaller
    • Rust (rust-server): @metaswitch
    • Scala (scalaz & http4s): @tbrown1979
    • Swift: @tkqubo
    • Swift 3: @hexelon
    • Swift 4: @ehyche
    • TypeScript (Node): @mhardorf
    • TypeScript (Angular1): @mhardorf
    • TypeScript (Fetch): @leonyu
    • TypeScript (Angular2): @roni-frantchi
    • TypeScript (jQuery): @bherila
  • Server Stubs
    • Ada: @stcarrez
    • C# ASP.NET5: @jimschubert
    • C# NancyFX: @mstefaniuk
    • C++ Pistache: @sebymiano
    • C++ Restbed: @stkrwork
    • Erlang Server: @galaxie
    • Go Server: @guohuang
    • Haskell Servant: @algas
    • Java MSF4J: @sanjeewa-malalgoda
    • Java Spring Boot: @diyfr
    • Java Undertow: @stevehu
    • Java Play Framework: @JFCote
    • Java PKMST: @anshu2185 @sanshuman @rkumar-pk @ninodpillai
    • JAX-RS RestEasy: @chameleon82
    • JAX-RS CXF: @hiveship
    • JAX-RS CXF (CDI): @nickcmaynard
    • JAX-RS RestEasy (JBoss EAP): @jfiala
    • Kotlin: @jimschubert
    • PHP Lumen: @abcsun
    • PHP Slim: @jfastnacht
    • PHP Symfony: @ksm2
    • PHP Zend Expressive (with Path Handler): @Articus
    • Ruby on Rails 5: @zlx
    • Rust (rust-server): @metaswitch
    • Scala Finch: @jimschubert
    • Scala Lagom: @gmkumar2005
  • Documentation
    • HTML Doc 2: @jhitchcock
    • Confluence Wiki: @jhitchcock
  • Configuration
    • Apache2: @stkrwork

How to join the core team

Here are the requirements to become a core team member:

To become a Template Creator, simply submit a PR for new API client (e.g. Rust, Elixir) or server stub (e.g. Ruby Grape) generator.

Swagger Codegen Technical Committee

Members of the Swagger Codegen technical committee shoulder the following responsibilities:

  • Provides guidance and direction to other users
  • Reviews pull requests and issues
  • Improves the generator by making enhancements, fixing bugs or updating documentations
  • Sets the technical direction of the generator

Who is eligible? Those who want to join must have at least 3 PRs merged into a generator. (Exceptions can be granted to template creators or contributors who have made a lot of code changes with less than 3 merged PRs)

Members of Technical Committee

Languages Member (join date)
ActionScript
Ada @stcarrez (2018/02)
Android
Apex
Bash @kenjones-cisco (2017/09)
C++
C# @mandrean (2017/08)
Clojure
Dart @ircecho (2017/07)
Eiffel
Elixir
Elm
Erlang
Groovy
Go
Haskell
Java
Kotlin
Lua
NodeJS/Javascript @CodeNinjai (2017/07)
ObjC
Perl
PHP @dkarlovi (2017/07) @mandrean (2017/08)
Python @kenjones-cisco (2017/11)
R
Ruby @zlx (2017/09)
Rust
Scala
Swift @ehyche (2017/08)
TypeScript

Security contact

Please disclose any security-related issues or vulnerabilities by emailing [email protected], instead of using the public issue tracker.

License information on Generated Code

The Swagger Codegen project is intended as a benefit for users of the Swagger / Open API Specification. The project itself has the License as specified. In addition, please understand the following points:

  • The templates included with this project are subject to the License.
  • Generated code is intentionally not subject to the parent project license

When code is generated from this project, it shall be considered AS IS and owned by the user of the software. There are no warranties--expressed or implied--for generated code. You can do what you wish with it, and once generated, the code is your responsibility and subject to the licensing terms that you deem appropriate.

License

Copyright 2019 SmartBear Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

swagger-codegen's People

Contributors

ackintosh avatar arnested avatar casualjim avatar cbornet avatar davebaird avatar deepak-michael avatar epaul avatar fehguy avatar frantuma avatar geekerzp avatar guohuang avatar helmsdown avatar hiveship avatar hugomario avatar jaz-ah avatar jebentier avatar jfcote avatar jfiala avatar jimschubert avatar mstefaniuk avatar ralphdoe avatar rpidikiti avatar scop avatar scottrw93 avatar shyri avatar vrolijkx avatar webron avatar who avatar wing328 avatar xhh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swagger-codegen's Issues

Error when doing anything

I just cloned the repo and I can't run any of the examples. I get this error

java.lang.NoSuchMethodError: scala.Predef$.any2ArrowAssoc(Ljava/lang/Object;)Lscala/Predef$ArrowAssoc;
    at com.wordnik.swagger.model.SwaggerSerializers$.<init>(SwaggerModelSerializer.scala:18)
    at com.wordnik.swagger.model.SwaggerSerializers$.<clinit>(SwaggerModelSerializer.scala)
    at com.wordnik.swagger.codegen.Codegen.<init>(Codegen.scala:45)
    at com.wordnik.swagger.codegen.BasicGenerator.<init>(BasicGenerator.scala:44)
    at com.wordnik.swagger.codegen.BasicScalaGenerator.<init>(BasicScalaGenerator.scala:25)
    at Main$.<init>(ScalaPetstoreCodegen.scala:19)
    at Main$.<clinit>(ScalaPetstoreCodegen.scala)
    at Main.main(ScalaPetstoreCodegen.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71)
    at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139)
    at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
    at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
    at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
    at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
    at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45)
    at scala.tools.nsc.ScriptRunner.scala$tools$nsc$ScriptRunner$$runCompiled(ScriptRunner.scala:171)
    at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
    at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
    at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply$mcZ$sp(ScriptRunner.scala:157)
    at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
    at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
    at scala.tools.nsc.util.package$.trackingThreads(package.scala:51)
    at scala.tools.nsc.util.package$.waitingForThreads(package.scala:35)
    at scala.tools.nsc.ScriptRunner.withCompiledScript(ScriptRunner.scala:130)
    at scala.tools.nsc.ScriptRunner.runScript(ScriptRunner.scala:188)
    at scala.tools.nsc.ScriptRunner.runScriptAndCatch(ScriptRunner.scala:201)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:76)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

I compiled with ./sbt assembly and ran ./bin/scala-petstore.sh on OSX

Added support for generate Javadoc

Hi.

It seems the generation of Javadoc is not supported so far. I think it will be a great feature to add. The description of parameters can be taken from the JSON spec so it should be straightforward.

Error when generating static docs

running ./static-docs.sh returns this, noticed the scala error at the bottom, which may or may not be the main problem,but my docs only list the available operations on the left, clicking on one goes to the server root.

Detected sbt version 0.12.3
[info] Loading project definition from /Users/jasonsykes/Downloads/swagger-codegen-master/project
[info] Set current project to swagger-codegen (in build file:/Users/jasonsykes/Downloads/swagger-codegen-master/)
[warn] Credentials file /Users/jasonsykes/.ivy2/.credentials does not exist
[info] Running SwaggerDocGenerator http://localhost/rest/app/_.json
looking at base path http://localhost/rest
calling: http://localhost/rest/app
calling: http://localhost/rest/app/{container}/
WARNING! Unable to read API http://localhost/rest/app/{container}/
calling: http://localhost/rest/app/{container}/{file_path}
WARNING! Unable to read API http://localhost/rest/app/{container}/{file_path}
calling: http://localhost/rest/app/{container}/{folder_path}/
WARNING! Unable to read API http://localhost/rest/app/{container}/{folder_path}/
swagger version: 1.1
basePath: http://localhost/rest

api version: 1.0

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
wrote model samples/docs/swagger-static-docs/src/main/webapp/models/Containers.html
wrote model samples/docs/swagger-static-docs/src/main/webapp/models/Folder.html
wrote model samples/docs/swagger-static-docs/src/main/webapp/models/File.html
wrote model samples/docs/swagger-static-docs/src/main/webapp/models/Container.html
wrote model samples/docs/swagger-static-docs/src/main/webapp/models/FoldersAndFiles.html
wrote api samples/docs/swagger-static-docs/src/main/webapp/operations/AppApi.html
copied samples/docs/swagger-static-docs/pom.xml
copied samples/docs/swagger-static-docs/src/main/webapp/assets/css/bootstrap-responsive.css
copied samples/docs/swagger-static-docs/src/main/webapp/assets/css/bootstrap.css
copied samples/docs/swagger-static-docs/src/main/webapp/assets/css/style.css
copied samples/docs/swagger-static-docs/src/main/webapp/assets/images/logo.png
copied samples/docs/swagger-static-docs/src/main/webapp/assets/js/bootstrap.js
copied samples/docs/swagger-static-docs/src/main/webapp/assets/js/jquery-1.8.3.min.js
copied samples/docs/swagger-static-docs/src/main/webapp/assets/js/main.js
wrote samples/docs/swagger-static-docs/src/main/webapp/index.html
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at scala.tools.nsc.util.WorkScheduler.waitForMoreWork(WorkScheduler.scala:16)
at scala.tools.nsc.interactive.PresentationCompilerThread$$anonfun$run$1.apply$mcZ$sp(PresentationCompilerThread.scala:21)
at scala.tools.nsc.io.NullLogger$.logreplay(Replayer.scala:38)
at scala.tools.nsc.interactive.PresentationCompilerThread.run(PresentationCompilerThread.scala:21)

here is the json:

{
    "basePath": "http://localhost/rest",
    "swaggerVersion": "1.1",
    "apiVersion": "1.0",
    "resourcePath": "/app",
    "apis": [
        {
            "path": "/app",
            "operations": [
                {
                    "httpMethod": "GET",
                    "summary": "List all containers.",
                    "nickname": "getContainers",
                    "responseClass": "Containers",
                    "parameters": [
                        {
                            "name": "include_properties",
                            "description": "Return all properties of the container, if any.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "List the names of the available containers in this storage. Use 'include_properties' to include any properties of the containers."
                },
                {
                    "httpMethod": "POST",
                    "summary": "Create one or more containers.",
                    "nickname": "createContainers",
                    "responseClass": "Containers",
                    "parameters": [
                        {
                            "name": "data",
                            "description": "Array of containers to create.",
                            "allowMultiple": false,
                            "dataType": "Containers",
                            "paramType": "body",
                            "required": true
                        },
                        {
                            "name": "check_exist",
                            "description": "If true, the request fails when the container to create already exists.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Post data should be a single container definition or an array of container definitions."
                },
                {
                    "httpMethod": "DELETE",
                    "summary": "Delete one or more containers.",
                    "nickname": "deleteContainers",
                    "responseClass": "Containers",
                    "parameters": [
                        {
                            "name": "data",
                            "description": "Array of containers to delete.",
                            "allowMultiple": false,
                            "dataType": "Containers",
                            "paramType": "body",
                            "required": true
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Post data should be a single container definition or an array of container definitions."
                }
            ],
            "description": "Operations available for File Storage Service."
        },
        {
            "path": "/app/{container}/",
            "operations": [
                {
                    "httpMethod": "GET",
                    "summary": "List the container's properties, including folders and files.",
                    "nickname": "getContainer",
                    "responseClass": "FoldersAndFiles",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "The name of the container you want to retrieve the contents.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "include_properties",
                            "description": "Return all properties of the container, if any.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "include_folders",
                            "description": "Include folders in the returned listing.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": true
                        },
                        {
                            "name": "include_files",
                            "description": "Include files in the returned listing.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": true
                        },
                        {
                            "name": "full_tree",
                            "description": "List the contents of all sub-folders as well.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "zip",
                            "description": "Return the zipped content of the folder.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Use 'include_properties' to get properties of the container. Use the 'include_folders' and/or 'include_files' to return a listing."
                },
                {
                    "httpMethod": "POST",
                    "summary": "Add folders and/or files to the container.",
                    "nickname": "createContainer",
                    "responseClass": "FoldersAndFiles",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "The name of the container you want to put the contents.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "url",
                            "description": "The full URL of the file to upload.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "query",
                            "required": false
                        },
                        {
                            "name": "extract",
                            "description": "Extract an uploaded zip file into the container.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "clean",
                            "description": "Option when 'extract' is true, clean the current folder before extracting files and folders.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "check_exist",
                            "description": "If true, the request fails when the file or folder to create already exists.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "data",
                            "description": "Array of folders and/or files.",
                            "allowMultiple": false,
                            "dataType": "FoldersAndFiles",
                            "paramType": "body",
                            "required": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Post data as an array of folders and/or files."
                },
                {
                    "httpMethod": "PATCH",
                    "summary": "Update properties of the container.",
                    "nickname": "updateContainerProperties",
                    "responseClass": "Container",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "The name of the container you want to put the contents.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "data",
                            "description": "An array of container properties.",
                            "allowMultiple": false,
                            "dataType": "Container",
                            "paramType": "body",
                            "required": true
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Post data as an array of container properties."
                },
                {
                    "httpMethod": "DELETE",
                    "summary": "Delete the container or folders and/or files from the container.",
                    "nickname": "deleteContainer",
                    "responseClass": "FoldersAndFiles",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "The name of the container you want to delete from.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "data",
                            "description": "An array of folders and/or files to delete from the container.",
                            "allowMultiple": false,
                            "dataType": "FoldersAndFiles",
                            "paramType": "body",
                            "required": true
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Careful, this deletes the requested container and all of its contents, unless there are posted specific folders and/or files."
                }
            ],
            "description": "Operations on containers."
        },
        {
            "path": "/app/{container}/{file_path}",
            "operations": [
                {
                    "httpMethod": "GET",
                    "summary": "Download the file contents and/or its properties.",
                    "nickname": "getFile",
                    "responseClass": "File",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "Name of the container where the file exists.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "file_path",
                            "description": "Path and name of the file to retrieve.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "include_properties",
                            "description": "Return properties of the file.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "content",
                            "description": "Return the content as base64 of the file, only applies when 'include_properties' is true.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "download",
                            "description": "Prompt the user to download the file from the browser.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container, folder, or file does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "By default, the file is streamed to the browser. Use the 'download' parameter to prompt for download.\n             Use the 'include_properties' parameter (optionally add 'content' to include base64 content) to list properties of the file."
                },
                {
                    "httpMethod": "POST",
                    "summary": "Create a new file.",
                    "nickname": "createFile",
                    "responseClass": "File",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "Name of the container where the file exists.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "file_path",
                            "description": "Path and name of the file to create.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "check_exist",
                            "description": "If true, the request fails when the file to create already exists.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false
                        },
                        {
                            "name": "properties",
                            "description": "Properties of the file.",
                            "allowMultiple": false,
                            "dataType": "File",
                            "paramType": "body",
                            "required": false
                        },
                        {
                            "name": "content",
                            "description": "The content of the file.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "body",
                            "required": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container or folder does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Post data should be the contents of the file or an object with file properties."
                },
                {
                    "httpMethod": "PUT",
                    "summary": "Update content of the file.",
                    "nickname": "updateFile",
                    "responseClass": "File",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "Name of the container where the file exists.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "file_path",
                            "description": "Path and name of the file to update.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "content",
                            "description": "The content of the file.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "body",
                            "required": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container, folder, or file does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Post data should be the contents of the file."
                },
                {
                    "httpMethod": "PATCH",
                    "summary": "Update properties of the file.",
                    "nickname": "updateFileProperties",
                    "responseClass": "File",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "Name of the container where the file exists.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "file_path",
                            "description": "Path and name of the file to update.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "properties",
                            "description": "Properties of the file.",
                            "allowMultiple": false,
                            "dataType": "File",
                            "paramType": "body",
                            "required": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container, folder, or file does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Post data should be the file properties."
                },
                {
                    "httpMethod": "DELETE",
                    "summary": "Delete the file.",
                    "nickname": "deleteFile",
                    "responseClass": "File",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "Name of the container where the file exists.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "file_path",
                            "description": "Path and name of the file to delete.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container, folder, or file does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Careful, this removes the given file from the storage."
                }
            ],
            "description": "Operations on individual files."
        },
        {
            "path": "/app/{container}/{folder_path}/",
            "operations": [
                {
                    "httpMethod": "GET",
                    "summary": "List the folder's properties, or sub-folders and files.",
                    "nickname": "getFolder",
                    "responseClass": "FoldersAndFiles",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "The name of the container from which you want to retrieve contents.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "folder_path",
                            "description": "The path of the folder you want to retrieve. This can be a sub-folder, with each level separated by a '/'",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "include_properties",
                            "description": "Return all properties of the folder, if any.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "include_folders",
                            "description": "Include folders in the returned listing.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": true
                        },
                        {
                            "name": "include_files",
                            "description": "Include files in the returned listing.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": true
                        },
                        {
                            "name": "full_tree",
                            "description": "List the contents of all sub-folders as well.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "zip",
                            "description": "Return the zipped content of the folder.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container or folder does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Use with no parameters to get properties of the folder or use the 'include_folders' and/or 'include_files' to return a listing."
                },
                {
                    "httpMethod": "POST",
                    "summary": "Create one or more sub-folders and/or files.",
                    "nickname": "createFolder",
                    "responseClass": "FoldersAndFiles",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "The name of the container where you want to put the contents.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "folder_path",
                            "description": "The path of the folder where you want to put the contents. This can be a sub-folder, with each level separated by a '/'",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "url",
                            "description": "The full URL of the file to upload.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "query",
                            "required": false
                        },
                        {
                            "name": "extract",
                            "description": "Extract an uploaded zip file into the folder.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "clean",
                            "description": "Option when 'extract' is true, clean the current folder before extracting files and folders.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "check_exist",
                            "description": "If true, the request fails when the file or folder to create already exists.",
                            "allowMultiple": false,
                            "dataType": "boolean",
                            "paramType": "query",
                            "required": false,
                            "defaultValue": false
                        },
                        {
                            "name": "data",
                            "description": "Array of folders and/or files.",
                            "allowMultiple": false,
                            "dataType": "FoldersAndFiles",
                            "paramType": "body",
                            "required": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Post data as an array of folders and/or files. Folders are created if they do not exist"
                },
                {
                    "httpMethod": "PATCH",
                    "summary": "Update folder properties.",
                    "nickname": "updateFolderProperties",
                    "responseClass": "Folder",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "The name of the container where you want to put the contents.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "folder_path",
                            "description": "The path of the folder you want to update. This can be a sub-folder, with each level separated by a '/'",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "data",
                            "description": "Array of folder properties.",
                            "allowMultiple": false,
                            "dataType": "FoldersAndFiles",
                            "paramType": "body",
                            "required": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container or folder does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Post data as an array of folder properties."
                },
                {
                    "httpMethod": "DELETE",
                    "summary": "Delete one or more sub-folders and/or files.",
                    "nickname": "deleteFolder",
                    "responseClass": "FoldersAndFiles",
                    "parameters": [
                        {
                            "name": "container",
                            "description": "The name of the container where the folder exists.",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "folder_path",
                            "description": "The path of the folder where you want to delete contents. This can be a sub-folder, with each level separated by a '/'",
                            "allowMultiple": false,
                            "dataType": "string",
                            "paramType": "path",
                            "required": true
                        },
                        {
                            "name": "data",
                            "description": "Array of folder and files to delete.",
                            "allowMultiple": false,
                            "dataType": "FoldersAndFiles",
                            "paramType": "body",
                            "required": false
                        }
                    ],
                    "errorResponses": [
                        {
                            "reason": "Bad Request - Request does not have a valid format, all required parameters, etc.",
                            "code": 400
                        },
                        {
                            "reason": "Unauthorized Access - No currently valid session available.",
                            "code": 401
                        },
                        {
                            "reason": "Not Found - Requested container does not exist.",
                            "code": 404
                        },
                        {
                            "reason": "System Error - Specific reason is included in the error message.",
                            "code": 500
                        }
                    ],
                    "notes": "Careful, this deletes the requested folder and all of its contents, unless there are posted specific sub-folders and/or files."
                }
            ],
            "description": "Operations on folders."
        }
    ],
    "models": {
        "Containers": {
            "id": "Containers",
            "properties": {
                "container": {
                    "type": "Array",
                    "description": "An array of containers.",
                    "items": {
                        "$ref": "Container"
                    }
                }
            }
        },
        "Container": {
            "id": "Container",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "Identifier/Name for the container."
                },
                "path": {
                    "type": "string",
                    "description": "Same as name for the container."
                },
                "last_modified": {
                    "type": "string",
                    "description": "A GMT date timestamp of when the container was last modified."
                },
                "_property_": {
                    "type": "string",
                    "description": "Storage type specific properties."
                },
                "metadata": {
                    "type": "Array",
                    "description": "An array of name-value pairs.",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "FoldersAndFiles": {
            "id": "FoldersAndFiles",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "Identifier/Name for the current folder, localized to requested folder resource."
                },
                "path": {
                    "type": "string",
                    "description": "Full path of the folder, from the service including container."
                },
                "container": {
                    "type": "string",
                    "description": "Container for the current folder."
                },
                "last_modified": {
                    "type": "string",
                    "description": "A GMT date timestamp of when the folder was last modified."
                },
                "_property_": {
                    "type": "string",
                    "description": "Storage type specific properties."
                },
                "metadata": {
                    "type": "Array",
                    "description": "An array of name-value pairs.",
                    "items": {
                        "type": "string"
                    }
                },
                "folder": {
                    "type": "Array",
                    "description": "An array of contained folders.",
                    "items": {
                        "$ref": "Folder"
                    }
                },
                "file": {
                    "type": "Array",
                    "description": "An array of contained files.",
                    "items": {
                        "$ref": "File"
                    }
                }
            }
        },
        "Folder": {
            "id": "Folder",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "Identifier/Name for the folder, localized to requested folder resource."
                },
                "path": {
                    "type": "string",
                    "description": "Full path of the folder, from the service including container."
                },
                "last_modified": {
                    "type": "string",
                    "description": "A GMT date timestamp of when the folder was last modified."
                },
                "_property_": {
                    "type": "string",
                    "description": "Storage type specific properties."
                },
                "metadata": {
                    "type": "Array",
                    "description": "An array of name-value pairs.",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "File": {
            "id": "File",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "Identifier/Name for the file, localized to requested folder resource."
                },
                "path": {
                    "type": "string",
                    "description": "Full path of the file, from the service including container."
                },
                "content_type": {
                    "type": "string",
                    "description": "The media type of the content of the file."
                },
                "content_length": {
                    "type": "string",
                    "description": "Size of the file in bytes."
                },
                "last_modified": {
                    "type": "string",
                    "description": "A GMT date timestamp of when the file was last modified."
                },
                "_property_": {
                    "type": "string",
                    "description": "Storage type specific properties."
                },
                "metadata": {
                    "type": "Array",
                    "description": "An array of name-value pairs.",
                    "items": {
                        "type": "string"
                    }
                }
            }
        }
    }
}```

invalid resource json does not produce error notice

I had an issue because of a json formatting error, but no notice of json error was shown.

Specifically, extra closing braces may not be noticed, leading to silent failures.
example added to petstore example.

The json libraries are not checking for unexpected trailing characters, often from incorrect json braces.

  "models": {
    "Tag": {
      "id": "Tag",
      "properties": {
        "name": {
          "type": "string"
        },
        "id": {
          "type": "integer",
          "format": "int64"
        }
      } }
    },...

running the codegen with this addition shows a missing model warning, but no report of bad json.

base path is src/test/resources/petstore-1.2
version: 1.2 basePath: src/test/resources/petstore-1.2 apiKey: Some(?api_key=special-key)
api.path: /pet
api.path: /store
api.path: /user
swagger version: 1.2
basePath: 
api version: 1.0.0
missing models: Set(Pet)
wrote model samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/User.java
wrote model samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Order.java
wrote api samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java
wrote api samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java
wrote api samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java
wrote samples/client/petstore/java/src/main/java/com/wordnik/client//ApiInvoker.java
wrote samples/client/petstore/java/src/main/java/com/wordnik/client//JsonUtil.java
wrote samples/client/petstore/java/src/main/java/com/wordnik/client//ApiException.java
wrote samples/client/petstore/java/pom.xml

Build is not working

Hi,

I am trying to run the ./sbt assembly step but it gets "killed" with no specific abort message (that's the last message I see on the output). When I subsequently try to execute one of the examples I get the error:

swagger-codegen# ./bin/java-petstore.sh
/usr/swagger/swagger-codegen/samples/client/petstore/java/JavaPetstoreCodegen.scala:17: error: object wordnik is not a member of package com
import com.wordnik.swagger.codegen.BasicJavaGenerator

My request to you is: could you please go through the steps of the README file? I think you will be able to reproduce it easily (a colleague just got it reproduced in his windows environment as well).

Thanks and regards,

Pieter.

Parsing exception with swagger interface generated with grape-swagger gem

I have a Ruby project that defines a REST API using the grape gem. I am generating the swagger definition with the grape-swagger gem. The swagger definition grape-swagger generates works fine with swagger-ui. It's able to parse the display the API with no errors.

However, when I try to run the same swagger definition through the swagger-codegen validate.sh script, it throws the following exception:

[brian@master swagger-codegen]$ ./bin/validate.sh http://localhost:3000/swagger_doc.json
calling: http://localhost:3000/swagger_doc/users.json
org.json4s.MappingException: Did not find value which can be converted into java.lang.String
    at org.json4s.Extraction$.convert(Extraction.scala:419)
    at org.json4s.Extraction$.build$1(Extraction.scala:325)
    at org.json4s.Extraction$.org$json4s$Extraction$$extract0(Extraction.scala:372)
    at org.json4s.Extraction$.org$json4s$Extraction$$extract0(Extraction.scala:212)
    at org.json4s.Extraction$.extract(Extraction.scala:47)
    at org.json4s.JsonAST$JValue.extract(JsonAST.scala:384)
    at com.wordnik.swagger.model.SwaggerSerializers$OperationSerializer$$anonfun$$init$$6$$anonfun$apply$27.apply(SwaggerModelSerializer.scala:139)
    at com.wordnik.swagger.model.SwaggerSerializers$OperationSerializer$$anonfun$$init$$6$$anonfun$apply$27.apply(SwaggerModelSerializer.scala:132)
    at org.json4s.CustomSerializer$$anonfun$deserialize$2.apply(Formats.scala:273)
    at org.json4s.CustomSerializer$$anonfun$deserialize$2.apply(Formats.scala:271)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:46)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at org.json4s.Extraction$.newInstance$1(Extraction.scala:293)
    at org.json4s.Extraction$.build$1(Extraction.scala:326)
    at org.json4s.Extraction$$anonfun$19.apply(Extraction.scala:316)
    at org.json4s.Extraction$$anonfun$19.apply(Extraction.scala:316)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:194)
    at scala.collection.immutable.List.map(List.scala:45)
    at org.json4s.Extraction$.newCollection$1(Extraction.scala:316)
    at org.json4s.Extraction$.build$1(Extraction.scala:333)
    at org.json4s.Extraction$.org$json4s$Extraction$$extract0(Extraction.scala:372)
    at org.json4s.Extraction$.org$json4s$Extraction$$extract0(Extraction.scala:212)
    at org.json4s.Extraction$.extract(Extraction.scala:47)
    at org.json4s.JsonAST$JValue.extract(JsonAST.scala:384)
    at com.wordnik.swagger.model.SwaggerSerializers$ApiDescriptionSerializer$$anonfun$$init$$4$$anonfun$apply$18.apply(SwaggerModelSerializer.scala:101)
    at com.wordnik.swagger.model.SwaggerSerializers$ApiDescriptionSerializer$$anonfun$$init$$4$$anonfun$apply$18.apply(SwaggerModelSerializer.scala:95)
    at org.json4s.CustomSerializer$$anonfun$deserialize$2.apply(Formats.scala:273)
    at org.json4s.CustomSerializer$$anonfun$deserialize$2.apply(Formats.scala:271)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:46)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at org.json4s.Extraction$.newInstance$1(Extraction.scala:293)
    at org.json4s.Extraction$.build$1(Extraction.scala:326)
    at org.json4s.Extraction$$anonfun$19.apply(Extraction.scala:316)
    at org.json4s.Extraction$$anonfun$19.apply(Extraction.scala:316)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:194)
    at scala.collection.immutable.List.map(List.scala:45)
    at org.json4s.Extraction$.newCollection$1(Extraction.scala:316)
    at org.json4s.Extraction$.build$1(Extraction.scala:333)
    at org.json4s.Extraction$.org$json4s$Extraction$$extract0(Extraction.scala:372)
    at org.json4s.Extraction$.org$json4s$Extraction$$extract0(Extraction.scala:212)
    at org.json4s.Extraction$.extract(Extraction.scala:47)
    at org.json4s.JsonAST$JValue.extract(JsonAST.scala:384)
    at com.wordnik.swagger.model.SwaggerSerializers$ApiListingSerializer$$anonfun$$init$$1$$anonfun$apply$2.apply(SwaggerModelSerializer.scala:32)
    at com.wordnik.swagger.model.SwaggerSerializers$ApiListingSerializer$$anonfun$$init$$1$$anonfun$apply$2.apply(SwaggerModelSerializer.scala:24)
    at org.json4s.CustomSerializer$$anonfun$deserialize$2.apply(Formats.scala:273)
    at org.json4s.CustomSerializer$$anonfun$deserialize$2.apply(Formats.scala:271)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:46)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)
    at org.json4s.Extraction$.newInstance$1(Extraction.scala:293)
    at org.json4s.Extraction$.build$1(Extraction.scala:326)
    at org.json4s.Extraction$.org$json4s$Extraction$$extract0(Extraction.scala:372)
    at org.json4s.Extraction$.org$json4s$Extraction$$extract0(Extraction.scala:212)
    at org.json4s.Extraction$.extract(Extraction.scala:47)
    at org.json4s.JsonAST$JValue.extract(JsonAST.scala:384)
    at com.wordnik.swagger.codegen.util.ApiExtractor$$anonfun$fetchApiListings$1.apply(ApiExtractor.scala:42)
    at com.wordnik.swagger.codegen.util.ApiExtractor$$anonfun$fetchApiListings$1.apply(ApiExtractor.scala:34)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:194)
    at scala.collection.immutable.List.map(List.scala:45)
    at com.wordnik.swagger.codegen.util.ApiExtractor$.fetchApiListings(ApiExtractor.scala:34)
    at com.wordnik.swagger.codegen.spec.Validator$.main(Validator.scala:48)
    at com.wordnik.swagger.codegen.spec.Validator.main(Validator.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:78)
    at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:24)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:88)
    at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:78)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
    at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33)
    at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:40)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:56)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

Tracing through the scala code, it appears that the OperationSerializer is expecting a list of keys to be in the json document it's parsing. Specifically, the stack trace seems to be pointing to the missing "responseClass" key in the json document.

Unfortunately, the grape-swagger gem doesn't generate this key. When I curl the api that swagger-codegen is trying to parse (http://localhost:3000/swagger_doc/users.json), it only contains the following keys (notes, summary, nickname, httpMethod, parameters). See below:

[brian@master swagger-codegen]$ curl http://localhost:3000/swagger_doc/users.json
{
    "apiVersion": "v1",
    "swaggerVersion": "1.1",
    "basePath": "http://localhost:3000",
    "resourcePath": "",
    "apis": [
        {
            "path": "/v1/users/lock.{format}",
            "operations": [
                {
                    "notes": null,
                    "summary": "Lock User to ensure no more activity can resume with this users credentials",
                    "nickname": "POST--version-users-lock---format-",
                    "httpMethod": "POST",
                    "parameters": [
                        {
                            "paramType": "body",
                            "name": "auth_token",
                            "description": "Login Token",
                            "dataType": "String",
                            "required": true
                        }
                    ]
                }
            ]
        }
    ]
}

Since I am new to scala, it's difficult for me to understand exactly what is going on in the code. So it's possible I'm mis-reading this stack-trace. It's also possible the grape-swagger gem isn't fully implementing the swagger definition, in which case this is an issue for grape-swagger and not swagger-codegen (however that seems odd since swagger-ui can still parse it).

csharp template maps parameters named 'date' to DateTime

The csharp codegen template incorrectly maps parameters named 'date' to 'DateTime'. Note that this bug refers to the parameter name, not the data type which is correctly mapped.

eg
"apis": [
{
...
"operations": [
{
"....
"parameters": [
{
"paramType": "query",
"name": "date",
"description": "Some description",
"dataType": "Date",
"required": true,
"allowMultiple": false,
},
....

Gets converted by codegen template to:
public SomeResultType SomeMethod (DateTime DateTime);

This expected result is
public SomeResultType SomeMethod (DateTime date);

allow configurable api_key

Some folks don't use api_key as the key name, it should be configurable. Also, it should be able to be passed as a header param as well.

Issues with running ./bin/scala-petstore.sh (following README)

Hi there,

As a continuation of the issue reported at #64 I am still having problems following the readme as is. Now, upon execution of ./bin/scala-petstore.sh I get the following output at the end of the script running:

[info] Assembly up to date: /Users/william.conroy/Development/swagger-codegen/target/scala-2.9.2/swagger-codegen.jar
[success] Total time: 10 s, completed Jun 27, 2013 10:16:31 AM
/Users/william.conroy/Development/swagger-codegen/samples/client/petstore/scala/ScalaPetstoreCodegen.scala:17: error: object wordnik is not a member of package com
import com.wordnik.swagger.codegen.BasicScalaGenerator
^
/Users/william.conroy/Development/swagger-codegen/samples/client/petstore/scala/ScalaPetstoreCodegen.scala:20: error: not found: value generateClient
def main(args: Array[String]) = generateClient(args)
^
two errors found

It looks like some kind of issue with scala identifying the generators location...

model properties written in random order

The arguments in a model can be reordered in codegen which makes the generated models really painful to use. They should maintain their order with the spec file.

NoClassDefFoundError when running ./bin/scala-petstore.sh

Full output of error:
java.lang.NoClassDefFoundError: com/wordnik/swagger/model/ModelProperty
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getMethod0(Class.java:2670)
at java.lang.Class.getMethod(Class.java:1603)
at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:67)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45)
at scala.tools.nsc.ScriptRunner.scala$tools$nsc$ScriptRunner$$runCompiled(ScriptRunner.scala:171)
at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply$mcZ$sp(ScriptRunner.scala:157)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
at scala.tools.nsc.util.package$.trackingThreads(package.scala:51)
at scala.tools.nsc.util.package$.waitingForThreads(package.scala:35)
at scala.tools.nsc.ScriptRunner.withCompiledScript(ScriptRunner.scala:130)
at scala.tools.nsc.ScriptRunner.runScript(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner.runScriptAndCatch(ScriptRunner.scala:201)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:76)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Caused by: java.lang.ClassNotFoundException: com.wordnik.swagger.model.ModelProperty
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 25 more

Any ideas? No idea with this one myself...
Here are the various versions of software I'm using in relation to this:
uname -a
Darwin P21277.local 12.2.1 Darwin Kernel Version 12.2.1: Thu Oct 18 16:32:48 PDT 2012; root:xnu-2050.20.9~2/RELEASE_X86_64 x86_64

java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

mvn -version:
Apache Maven 3.0.3 (r1075438; 2011-03-01 02:31:09+0900)

Thanks!

It is presumptous to stick a format placeholder into the path without reason

generated swagger.rb code does:

# Stick a .{format} placeholder into the path if there isn't # one already or an actual format like json or xml # e.g. /words/blah => /words.{format}/blah unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s } p = p.sub(/^(\/?\w+)/, "\1.#{format}") end

which basicly forces a swagger API to parse URL for a format string, whereas the format could be perfectly determined by the Content-Type/Accept headers. It is also a buggy practice if the URL has a xml string for whatever other reason

java required parameter checking should occur prior to parameter use

Looking at api.mustache, note that a pathParam that is required will be used in apiInvoker.escapeString(), which will trigger a NullPointer rather than the expected ApiException

    // create path and map variables
    String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}};
...
    {{#requiredParamCount}}
    // verify required params are set
    if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) {
       throw new ApiException(400, "missing required params");
    }
    {{/requiredParamCount}}

Consider reordering the parameter checking to the top for consistent exception generation.

Note the generated code will show warnings about dead code in various IDEs when checking opaqueId == null.

  public String getOriginalId (String opaqueId) throws ApiException {
    // create path and map variables
    String path = "/originalid/{opaqueId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "opaqueId" + "\\}", apiInvoker.escapeString(opaqueId.toString()));
...
    // verify required params are set
    if(opaqueId == null ) {
       throw new ApiException(400, "missing required params");
    }

iOS Framework & UUID

Apps submitted to the App Store are no longer permitted to use the UUID methods. They are now part of the protected API. This means apps built with Wordnik.framework won't successfully submit to the App Store. Just something to think about.

"As of May 1st, Apple began enforcing this deprecation on all new app submissions, even for apps targeting earlier versions of iOS. Any use of uniqueIdentifier is grounds for immediate rejection of new binaries." http://nshipster.com/uuid-udid-unique-identifier/

Allowable values model range min / max difficulties

When using a swagger json file with a model that has a range, there are some problems.

  1. SwaggerModelSerializer.scala uses keywords 'min' and 'max', where the spec uses 'minimum' and 'maximum'. See https://github.com/wordnik/swagger-core/wiki/Datatypes
  2. using 'min' and 'max', the AllowableRangeValues object is not created for simple property descriptors
  "properties": {
    "happiness": {
      "type": "integer",
      "format": "int32",
      "description": "how happy the Pet appears to be, where 10 is 'extremely happy'",
      "min": 1,
      "max": 10
    },

The snippet to extract min/max (used several times in different places) fails to pull string, integer, or double values

          val min = (json \ "min") match {
            case e: JObject => e.extract[String]
            case _ => ""
          }
          val max = (json \ "max") match {
            case e: JObject => e.extract[String]
            case _ => ""
          }

using this works

          val min = (json \ "min") match {
            case e: JObject => e.extract[String]
            case e: JString => e.s
            case e: JInt => e.num.toString
            case e: JDouble => e.num.toString          
            case _ => ""
          }
          val max = (json \ "max") match {
            case e: JObject => e.extract[String]
            case e: JString => e.s
            case e: JInt => e.num.toString
            case e: JDouble => e.num.toString          
            case _ => ""
          }
  1. probably this issue will occur in other places that provide min/max constraints, such as parameter handling, etc.

  2. probably should pull extraction into function.

eta. fix updated scala

codegen fails on Windows

Getting an error when executing my runner on Windows. Most likely due to escaping paths and File.separator is different on Windows than it is on POSIX systems.

java.lang.StringIndexOutOfBoundsException: String index out of range: 1
        at java.lang.String.charAt(String.java:686)
        at java.util.regex.Matcher.appendReplacement(Matcher.java:703)
        at java.util.regex.Matcher.replaceAll(Matcher.java:813)
        at java.lang.String.replaceAll(String.java:2189)
        at com.wordnik.swagger.codegen.BasicGenerator$$anonfun$prepareModelMap$2.apply(BasicGenerator.scala:154)
        at com.wordnik.swagger.codegen.BasicGenerator$$anonfun$prepareModelMap$2.apply(BasicGenerator.scala:144)

HTTP Request method type not being set correctly in Python 3 generation

In swagger.mustache, the "MethodRequest"'s method get_method wasn't properly being called. I removed this method and it uses urllib's default get_method's and chooses a POST request when the 'data' parameter is set. It works after doing this, but there may be a better solution. Probably the Pyton 2 -> 3 refactor of urllib/urllib2 caused this.

java.lang.IncompatibleClassChangeError when running examples

I cloned the git repo (a2bff39), ran "mvn package", and then attempted to generate the client for the example petstore with "./bin/scala-petstore.sh". I get the following stack-trace:

[brian@master swagger-codegen]$ ./bin/scala-petstore.sh
java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at com.wordnik.swagger.model.SwaggerSerializers$ModelSerializer.<init>(SwaggerModelSerializer.scala:207)
    at com.wordnik.swagger.model.SwaggerSerializers$.<init>(SwaggerModelSerializer.scala:12)
    at com.wordnik.swagger.model.SwaggerSerializers$.<clinit>(SwaggerModelSerializer.scala)
    at com.wordnik.swagger.codegen.Codegen.<init>(Codegen.scala:45)
    at com.wordnik.swagger.codegen.BasicGenerator.<init>(BasicGenerator.scala:42)
    at com.wordnik.swagger.codegen.BasicScalaGenerator.<init>(BasicScalaGenerator.scala:25)
    at Main$.<init>(ScalaPetstoreCodegen.scala:19)
    at Main$.<clinit>(ScalaPetstoreCodegen.scala)
    at Main.main(ScalaPetstoreCodegen.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71)
    at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139)
    at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
    at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
    at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
    at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
    at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45)
    at scala.tools.nsc.ScriptRunner.scala$tools$nsc$ScriptRunner$$runCompiled(ScriptRunner.scala:171)
    at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
    at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
    at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply$mcZ$sp(ScriptRunner.scala:157)
    at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
    at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
    at scala.tools.nsc.util.package$.trackingThreads(package.scala:51)
    at scala.tools.nsc.util.package$.waitingForThreads(package.scala:35)
    at scala.tools.nsc.ScriptRunner.withCompiledScript(ScriptRunner.scala:130)
    at scala.tools.nsc.ScriptRunner.runScript(ScriptRunner.scala:188)
    at scala.tools.nsc.ScriptRunner.runScriptAndCatch(ScriptRunner.scala:201)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:76)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

I tried this with both JDK 1.6 and 1.7 and get the same results.

I am running maven version 3.0.4.

Execution stuck at wrote samples/client/petstore/java/pom.xml

Hi,

Thanks for fixing the URLs issue. Now I got a little further and checking if what I see is ok to exit by pressing Ctrl + C as its been stuck at "wrote samples/client/petstore/java/pom.xml" for over 20 minutes without getting back to the shell prompt.

[root@localhost swagger-codegen]# ./bin/java-petstore.sh
looking at base path http://petstore.swagger.wordnik.com/api/api-docs
calling: http://petstore.swagger.wordnik.com/api/api-docs/pet?api_key=special-key
calling: http://petstore.swagger.wordnik.com/api/api-docs/user?api_key=special-key
calling: http://petstore.swagger.wordnik.com/api/api-docs/store?api_key=special-key
swagger version: 1.2
basePath:

api version: 1.0.0

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
wrote model samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Pet.java
wrote model samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Category.java
wrote model samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Tag.java
wrote model samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/User.java
wrote model samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Order.java
wrote api samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java
wrote api samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java
wrote api samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java
wrote samples/client/petstore/java/src/main/java/com/wordnik/client//ApiInvoker.java
wrote samples/client/petstore/java/src/main/java/com/wordnik/client//JsonUtil.java
wrote samples/client/petstore/java/src/main/java/com/wordnik/client//ApiException.java
wrote samples/client/petstore/java/pom.xml

Trying to add a new template

When I add a new template I get an error message as seen below. I did compile it and I can see that in the JAR file.

/swagger-codegen/samples/client/summon/csharp/CSharpSummonCodegen.scala:17: error: BasicCsharpGenerator is not a member of com.wordnik.swagger.codegen import com.wordnik.swagger.codegen.BasicCsharpGenerator ^ /swagger-codegen/samples/client/summon/csharp/CSharpSummonCodegen.scala:19: error: not found: type BasicCsharpGenerator object CSharpSummonCodegen extends BasicCsharpGenerator { ^ /swagger-codegen/samples/client/summon/csharp/CSharpSummonCodegen.scala:20: error: not found: value generateClient def main(args: Array[String]) = generateClient(args) ^ three errors found

Ruby client should use lowercase file names

Line 39 from BasicRubyGenerator.scala:

  // template used for models
  modelTemplateFiles += "model.mustache" -> ".rb"

EDIT: I guess the change should come from https://github.com/wordnik/swagger-codegen/blob/master/src/main/scala/com/wordnik/swagger/codegen/BasicGenerator.scala

This should ensure the first character is lowercase. I wouldn't mind trying to fix this...it would be a fun bug to squash. I just have to learn some Scala first.

Suggested fix:

  1. Create BasicGenerator#modelFiles that returns an array of the model files (I have no idea what the scala appropriate data structure is here).
  2. In BasicRubyGenerator, override the method, call super on it, whatever way scala lets you do this, call map on the result and lowercase all the filenames.

Sinatra example not working

Hi,

Nice work with Swagger!

I'm having a bit of a problem getting the Sinatra example working though.

If I follow the instructions as then attempt to start the server as follows:

rackup -p 4567 config.ru

I get the following stack trace!

/Users/CarlBourne/Documents/GitHub/swagger-codegen/samples/server-generator/sinatra/templates/config.ru:1:in require': cannot load such file -- ./my_app (LoadError) from /Users/CarlBourne/Documents/GitHub/swagger-codegen/samples/server-generator/sinatra/templates/config.ru:1:inblock in

'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/builder.rb:55:in instance_eval' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/builder.rb:55:ininitialize'
from /Users/CarlBourne/Documents/GitHub/swagger-codegen/samples/server-generator/sinatra/templates/config.ru:in new' from /Users/CarlBourne/Documents/GitHub/swagger-codegen/samples/server-generator/sinatra/templates/config.ru:in'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/builder.rb:49:in eval' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/builder.rb:49:innew_from_string'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/builder.rb:40:in parse_file' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/server.rb:277:inbuild_app_and_options_from_config'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/server.rb:199:in app' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/server.rb:314:inwrapped_app'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/server.rb:250:in start' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/lib/rack/server.rb:141:instart'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rack-1.5.2/bin/rackup:4:in <top (required)>' from /usr/local/rvm/gems/ruby-2.0.0-p0/bin/rackup:23:inload'
from /usr/local/rvm/gems/ruby-2.0.0-p0/bin/rackup:23:in <main>' from /usr/local/rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:ineval'
from /usr/local/rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `'

I then tried running the app directly from my IDE and edited the config.ru file to:

require './lib/swaggering'
run Swaggering

This started the server OK but when I tried make a request directly to "http://localhost:4567/resources.json" in a browser, Sinatra returns it famous "Sinatra doesn’t know this ditty"

When I try with Swagger-UI it just complains about the cross-domain configuration.
"Can't read from server. It may not have the appropriate access-control-origin settings"

Any pointers would be much appreciated.

Best Regards

java headers with dash characters generate non-functional code

When the swagger json contains headers with -, the java codegen takes the header name as is, and uses it as a local variable name. This creates non-functional code.
Suggested fix is to have a 'codeParamName' paired with 'paramName', and map - to _

{
  "apiVersion": "1.0",
  "swaggerVersion": "1.2",
  "basePath": "http:/www.sample.com/mapi/v1",
  "resourcePath": "/content/",
  "apis": [ {
      "path": "/content/user-agreement",
      "operations": [ {
          "httpMethod": "GET",
          "summary": "Get localized user-agreement",
          "notes": "User Agreement based on the user's locale.",
          "responseClass": "string",
          "nickname": "userAgreement",
          "produces": ["text/html;charset=UTF-8"],
          "parameters": [ {
              "name": "Accept-Language",
              "description": "ISO code of language accepted",
              "paramType": "header",
              "required": false,
              "allowMultiple": false,
              "dataType": "string"
            }
          ]
        }
      ]
    }
  ],
  "models": {
  }
}

Generated code: note "String Accept-Language" which won't work.

  public String userAgreement (String Accept-Language) throws ApiException {
    // create path and map variables
    String path = "/content/user-agreement".replaceAll("\\{format\\}","json");

    // query params
    Map<String, String> queryParams = new HashMap<String, String>();
    Map<String, String> headerParams = new HashMap<String, String>();

    headerParams.put("Accept-Language", Accept-Language);
    try {
      String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
      if(response != null){
        return (String) ApiInvoker.deserialize(response, "", String.class);
      }
      else {
        return null;
      }
    } catch (ApiException ex) {
      if(ex.getCode() == 404) {
        return null;
      }
      else {
        throw ex;
      }
    }
  }

Parameters are assumed (incorrectly) to be valid parameter names in all languages

Parameters appear to be assumed (incorrectly) to be valid parameter names in all languages - so for example for services that may use query parameters that start with a dollar sign ($) - this generates invalid parameters in clients such as CSharp or Ruby.

Query/Form parameters starting with a dollar sign is really common if exposing OData compliant services via swagger.

Here's an example of an invalid method due to parameter that contains a $ sign:

public QueryResultsOfUser searchProjectAssignees (string projectId, string query, string $expand) {

It would be nice if a sanitized version of the parameter name was used in the API method signature for all clients, that then mapped to the correct string parameter name internally when constructing the request.

Unable to read from http://petstore.swagger.wordnik.com/api/api-docs.json

Hi,

I am trying to use the codegen and running in to the below issue when ran against the perstore apis. I got Java 1.7, Scala 2.9.2 and Maven 3.1.0 on CentOS
And cloned the repo and executed the following commands

  • ./sbt assembly
  • ./bin/java-petstore.sh --- Here I got the below exception

Also I tried to use the './bin/java-petstore-filemap.sh -DfileMap=src/test/resources/petstore' and still getting same error.

Thank you for the help in resolving this issue.

[root@localhost swagger-codegen]# ./bin/java-petstore.sh
java.lang.Exception: unable to read from http://petstore.swagger.wordnik.com/api/api-docs.json
at com.wordnik.swagger.codegen.BasicGenerator.generateClient(BasicGenerator.scala:59)
at Main$.main(JavaPetstoreCodegen.scala:20)
at Main.main(JavaPetstoreCodegen.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:78)
at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:24)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:88)
at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:78)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33)
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:40)
at scala.tools.nsc.ScriptRunner.scala$tools$nsc$ScriptRunner$$runCompiled(ScriptRunner.scala:171)
at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply$mcZ$sp(ScriptRunner.scala:157)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
at scala.tools.nsc.util.package$.waitingForThreads(package.scala:26)
at scala.tools.nsc.ScriptRunner.withCompiledScript(ScriptRunner.scala:130)
at scala.tools.nsc.ScriptRunner.runScript(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner.runScriptAndCatch(ScriptRunner.scala:201)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:58)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Caused by: java.io.FileNotFoundException: http://petstore.swagger.wordnik.com/api/api-docs.json?api_key=special-key
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1623)
at com.wordnik.swagger.codegen.util.RemoteUrl$class.urlToString(RemoteUrl.scala:13)
at com.wordnik.swagger.codegen.util.ResourceExtractor$.fetchListing(ResourceExtractor.scala:31)
at com.wordnik.swagger.codegen.BasicGenerator.generateClient(BasicGenerator.scala:57)

HTML in "implementation notes" is incorrectly HTML-encoded in comment headers of CSharp generated code.

When generating CSharp code, if swagger implementation notes contains HTML e.g. UL/LI list etc. - it becomes HTML encoded - and additionally the values can end up breaking over multiple lines, with only the first line starting with the "//" designating a comment.

This prevents the output from being compiled - here's an example of what that output looks like:

  /// <summary>
  /// Searches for assignees by partial name match &lt;strong&gt;Expanders:&lt;/strong&gt;&lt;br/&gt;&lt;ul&gt;&lt;li&gt;DisplayName&lt;/li&gt;
&lt;li&gt;Groups&lt;/li&gt;&lt;/ul&gt;
  /// </summary>
  /// <param name="projectId"></param>
  /// <param name="query"></param>
  /// <param name="$expand">Allows the specifying of eager-loading of related data which is returned in-line within the results of the request.</param>
  /// <returns></returns>

./bin/validate.sh causes java.lang.IncompatibleClassChangeError: Implementing class

Hi there.

I'm trying to validate a swagger JSON file using the validate.sh file. Running the command yields:

java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at com.wordnik.swagger.model.SwaggerSerializers$ModelSerializer.<init>(SwaggerModelSerializer.scala:272)
    at com.wordnik.swagger.model.SwaggerSerializers$.<init>(SwaggerModelSerializer.scala:16)
    at com.wordnik.swagger.model.SwaggerSerializers$.<clinit>(SwaggerModelSerializer.scala)
    at com.wordnik.swagger.codegen.util.ResourceExtractor$.<init>(ResourceExtractor.scala:27)
    at com.wordnik.swagger.codegen.util.ResourceExtractor$.<clinit>(ResourceExtractor.scala)
    at com.wordnik.swagger.codegen.spec.Validator$.main(Validator.scala:41)
    at com.wordnik.swagger.codegen.spec.Validator.main(Validator.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71)
    at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139)
    at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
    at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
    at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
    at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
    at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

My JSON file can be found here: http://stash.socialvi.be/api-docs.json

Any tips would be appreciated. I am surprised that the swagger project doesn't have an online validator.

Cheers.

swaggerSpec1_2.OperationSerializersTest failing during ./sbt assembly

swaggerSpec1_2.OperationSerializersTest has been failing for me when I run ./sbt assembly

Here's the output I'm getting from ./sbt assemblyhttps://gist.github.com/rlord/6372182

And here's my version info:

$ java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)
$ scala -version
Scala code runner version 2.9.3 -- Copyright 2002-2011, LAMP/EPFL
$ mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 00:44:56-0800)
Maven home: /usr/share/maven
Java version: 1.6.0_51, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"

I also tested this on a fresh, Ubuntu virtual machine, and got the same failing test, so I don't think it's a problem with OS X.

Am I doing something wrong?

A null item in JSON breaks python client when int is expected

I kept running into this error:

Traceback (most recent call last): File "testLocationsApi.py", line 6, in <module> L.getLocation(448, 'QVorMkxG') File "/Users/gsibble/Source/generated-code/sd_python/LocationsApi.py", line 178, in getLocation responseObject = self.apiClient.deserialize(response, 'Location') File "/Users/gsibble/Source/generated-code/sd_python/swagger.py", line 166, in deserialize value = attrType(value) TypeError: int() argument must be a string or a number, not 'NoneType'

When using the python generated client libraries. It appears that a null is being sent for a setting that a user has not established (it would usually be an integer). This is expected behavior for the API since it has not yet been set.

I would suggest checking for the None type before converting the value in that manner. I'm attempting to adjust it with my own fork right now, but don't really know Scala! Thanks in advance.

Organize commands using 37signals/sub

Check out https://github.com/37signals/sub.

Because swagger-codegen is heavily a command line tool, it would make sense that the commands would be organized in a predictable and well-documented manner sub looks like just the tool for this.

Instead of running $ ./bin/scala-petstore.sh from the root of swagger-codegen, package it as a sub command-line tool and you could run this (from anywhere):

$ swagger ruby http://petstore.swagger.wordnik.com/api/resources.json

This would likely require some reorganization of the file structure of this repo, but if anyone is interested, I could come up with a proposal and go on from there.

Problem with Model containing an `Array` property

I came across this while testing my api resourses.json with the validator

./bin/validate.sh http://localhost/restler3.dev/raw/swagger/resources.json "arul" ./swagger-errors.html

is throwing the following exception when my Author model contains a property called books of type Array

api.path: /resources/authors.{format}
calling: http://localhost/restler3.dev/raw/swagger/resources/authors.json?api_key=arul
swagger version: 1.1
basePath: http://localhost/restler3.dev/raw/swagger
api version: 1
java.lang.NullPointerException
    at com.wordnik.swagger.codegen.util.CoreUtils$$anonfun$extractModels$4$$anonfun$apply$11.apply(CoreUtils.scala:138)
    at com.wordnik.swagger.codegen.util.CoreUtils$$anonfun$extractModels$4$$anonfun$apply$11.apply(CoreUtils.scala:135)
    at scala.collection.Iterator$class.foreach(Iterator.scala:660)
    at scala.collection.JavaConversions$JMapWrapperLike$$anon$2.foreach(JavaConversions.scala:781)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:73)
    at scala.collection.JavaConversions$JMapWrapper.foreach(JavaConversions.scala:792)
    at com.wordnik.swagger.codegen.util.CoreUtils$$anonfun$extractModels$4.apply(CoreUtils.scala:135)
    at com.wordnik.swagger.codegen.util.CoreUtils$$anonfun$extractModels$4.apply(CoreUtils.scala:134)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
    at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:93)
    at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:93)
    at scala.collection.Iterator$class.foreach(Iterator.scala:660)
    at scala.collection.mutable.HashTable$$anon$1.foreach(HashTable.scala:157)
    at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:190)
    at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:43)
    at scala.collection.mutable.HashMap.foreach(HashMap.scala:93)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:194)
    at scala.collection.mutable.HashMap.map(HashMap.scala:43)
    at com.wordnik.swagger.codegen.util.CoreUtils$.extractModels(CoreUtils.scala:134)
    at com.wordnik.swagger.codegen.util.CoreUtils$$anonfun$extractAllModels$1.apply(CoreUtils.scala:45)
    at com.wordnik.swagger.codegen.util.CoreUtils$$anonfun$extractAllModels$1.apply(CoreUtils.scala:44)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at com.wordnik.swagger.codegen.util.CoreUtils$.extractAllModels(CoreUtils.scala:44)
    at com.wordnik.swagger.codegen.spec.SwaggerSpecValidator.validateResponseModels(SwaggerSpecValidator.scala:63)
    at com.wordnik.swagger.codegen.spec.SwaggerSpecValidator.validate(SwaggerSpecValidator.scala:57)
    at com.wordnik.swagger.codegen.spec.Validator$.main(Validator.scala:54)
    at com.wordnik.swagger.codegen.spec.Validator.main(Validator.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:78)
    at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:24)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:88)
    at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:78)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
    at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33)
    at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:40)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:56)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

Here is the /resources/authors.json for your reference

{
  "apiVersion": "1",
  "swaggerVersion": "1.1",
  "basePath": "http://localhost/restler3.dev/raw/swagger",
  "apis": [
    {
      "path": "/authors.{format}/{id}",
      "description": "API to list, modify Authors of the Restler",
      "operations": [
        {
          "httpMethod": "GET",
          "nickname": "authorsid",
          "responseClass": "Author",
          "parameters": [
            {
              "name": "id",
              "description": "Author ID . ",
              "paramType": "path",
              "required": true,
              "allowMultiple": false,
              "dataType": "string"
            }
          ],
          "summary": "Get Author for the specified Author ID",
          "notes": "Passing a valid author id, will result in getting details (name, email, author id) of the specific Author.",
          "errorResponses": [
            {
              "reason": "one or more of required fields missing",
              "code": 417
            },
            {
              "reason": "Author not found",
              "code": 404
            }
          ]
        }
      ]
    },
    {
      "path": "/authors.{format}",
      "description": "API to list, modify Authors of the Restler",
      "operations": [
        {
          "httpMethod": "POST",
          "nickname": "authors",
          "responseClass": "Array",
          "parameters": [
            {
              "name": "request_data",
              "description": "",
              "paramType": "path",
              "required": true,
              "allowMultiple": false,
              "dataType": "string"
            }
          ],
          "summary": "Create new Author",
          "notes": "",
          "errorResponses": [
            {
              "reason": "one or more of required fields missing",
              "code": 417
            }
          ]
        }
      ]
    },
    {
      "path": "/authors.{format}/{id}",
      "description": "API to list, modify Authors of the Restler",
      "operations": [
        {
          "httpMethod": "PUT",
          "nickname": "authorsid",
          "responseClass": "Array",
          "parameters": [
            {
              "name": "id",
              "description": "Author ID . ",
              "paramType": "path",
              "required": true,
              "allowMultiple": false,
              "dataType": "string"
            },
            {
              "name": "request_data",
              "description": "",
              "paramType": "path",
              "required": true,
              "allowMultiple": false,
              "dataType": "string"
            }
          ],
          "summary": "Update Author information",
          "notes": "",
          "errorResponses": [

          ]
        }
      ]
    },
    {
      "path": "/authors.{format}/something/{id}",
      "description": "API to list, modify Authors of the Restler",
      "operations": [
        {
          "httpMethod": "DELETE",
          "nickname": "authorssomethingid",
          "responseClass": "Array",
          "parameters": [
            {
              "name": "id",
              "description": "Author ID . ",
              "paramType": "path",
              "required": true,
              "allowMultiple": false,
              "dataType": "string"
            }
          ],
          "summary": "Delete Author by ID",
          "notes": "",
          "errorResponses": [

          ]
        }
      ]
    }
  ],
  "resourcePath": "/authors",
  "models": {
    "Author": {
      "id": "Author",
      "properties": {
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "age": {
          "type": "int"
        },
        "books": {
          "type": "Array"
        }
      }
    }
  }
}

if I remove , "books":{ "type":"Array"} validator is fine

Form post support in generated clients

Thank you for the great work on this project. I was implementing this on our api earlier today and I noticed a discrepancy in the swagger-ui and swagger-codegen projects. Support for defining and posting HTML forms was recently added to swagger-core and swagger-ui. I'm wondering if it was just a matter of time before post form support makes its way into swagger-codegen or if it is not on the roadmap. If there are not plans to add it anytime soon, I'm happy to send a pull request with the changes I made to support form submission in php and java. I'm afraid someone with other language expertise would need to check out the mustache templates in other languages. There's also the chance that I'm completely missing something conceptually. If so, please let me know. Thanks again for the great work.

Support for Produces or operation that serves a file download

Hello,

Thanks for your excellent work on swagger-codegen. I am attempting to use it to produce client libraries for an API in which one operation may return a response with a Content-Type of either "application/pdf", "application/csv", or "application/html" depending on a parameter. The response body will contain the bytes of a PDF, CSV, or HTML file.

If it helps, my swagger spec for this operation is more or less the following:

{
    "path":"/jobs/{job_id}/result",
    "description":"Job results",
    "operations":[{
      "httpMethod":"GET",
      "nickname":"getJobResult",
      "produces":["application/pdf","application/csv","application/html"],
      "responseClass":"byte",
      "parameters":[{
        "paramType":"path",
        "name":"job_id",
        "description":"job_id",
        "dataType":"string",
        "required":false,
        "allowMultiple":false,
        "defaultValue":null
      },{
        "paramType":"header",
        "name":"Accept",
        "description":"Accept",
        "dataType":"string",
        "required":false,
        "allowMultiple":false,
        "defaultValue":null
      }],
      "summary":"",
      "notes":"",
      "errorResponses":[]
}]
}

Any advice is greatly appreciated.

Missing License Info

I have noticed that the other swagger-* projects provide license information (ASL 2.0), which seems to be missing from this project.

For example:
https://github.com/wordnik/swagger-ui/blob/master/README.md#license
https://github.com/wordnik/swagger-core/blob/master/README.md#license

In order for us to use this specific library, we need to know what license is being used for swagger-codegen. If you could please update the docs to provide this information, the community would appreciate it.

Thanks!

/jd

Create statis js library

The dynamic ds library is nice, but we need a static one too to avoid calls to the server as well as allow easier introspection.

Commit 885cd36165f50ed26ddc2c30a34d784fc525e615 breaks the test

Hi!

I found out that the latest commit (885cd36) breaks the test suite and doesn't let to compile the whole project.

The reason is in

src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala

You should change the line 201

("method" -> x.httpMethod) ~

to

("hhtpMethod" -> x.httpMethod) ~

samples out of sync with current code generation output

When I clone the project and run the tools, run scala-petstore.sh, java-petstore.sh (and others?), the output files in the samples/ directory do not match the versions from the repo. I find this confusing - I don't know if I incorrectly ran the tools.
I also then worry that the generated code might not compile.

Especially when the output for the java code includes:

public array<Pet> findPetsByTags (String tags) throws ApiException {

As of commit [feb6c18] using scala-2.9.1-1

Nested models generation not working properly

Hello and thank you guys for this great project!

I'm using swagger-codegen to generate a Python library to call our APIs (documented with swagger-ui), but I'm having a problem with nesting models generation. I have something like this:

"models": {
    "A": {
        "id": "A",
        "properties": {
            "id": {
                "type": "int"
            },
            "b": {
                "type": "B"
            }
        }
    },
    "B": {
        "id": "B",
        "properties": {
            "id": {
                "type": "int"
            },
            "c": {
                "type": "C"
            }
        }
    },
    "C": {
        "id": "C",
        "properties": {
            "id": {
                "type": "int"
            },
            "d": {
                "type": "D"
            },
            "e": {
                "type": "E"
            }
        }
    },
    "D": {
        "id": "D",
        "properties": {
            …
        }
    },
    "E": {
        "id": "E",
        "properties": {
            …
        }
    }
}

When generating the code, I get models A, B and C, with C containing in its properties references to D and E, but D and E aren't generated. It's just at the third level of nesting that the problem occurs, all other models are correctly generated.

Any ideas?

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.