1. Vít Kotačka
  2. blog-rest-contract-first

Overview

HTTPS SSH

Contract-first REST service via Swagger & Gradle

An example project for demonstration of the contract-first approach for REST web services. It's implemented via help of Swagger and Gradle.

How to run the example

  1. Clone the repository.
  2. Run the command gradle jettyRun.
  3. Open a browser on URL http://localhost:4040/deep-thought/question
  4. See the JSON response in the browser.
  5. Browse the source code.

What if you're sitting behind a proxy?

New Gradle plugin mechanism (block plugins) doesn't work behind proxy. In that case, modify your build.gradle file in the following manner (put those lines at the beginning of the script):

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'gradle.plugin.org.hidetake:gradle-swagger-generator-plugin:2.4.2'
    }
}

apply plugin: 'org.hidetake.swagger.generator'

Moreover, you need to modify (or create) your $HOME/.gradle/gradle.properties in following way:

systemProp.http.proxyHost=<your-proxy-host>
systemProp.http.proxyPort=<your-proxy-port>
systemProp.http.nonProxyHosts=localhost|<other-non-proxy-host>
systemProp.https.proxyHost=<your-proxy-host>
systemProp.https.proxyPort=<your-proxy-port>
systemProp.https.nonProxyHosts=localhost|<other-non-proxy-host>