Code Monkey home page Code Monkey logo

generate-java-swagger-api's Introduction

generate-java-swagger-api

Overview

This is a Java project to build a stand-alone server generated from a Swagger Java object which implements the Swagger spec. You can find out more about both the spec and the framework at http://swagger.io.

We could also just run a Apache httpd to expose all generated JSON and generate swagger UI pages that point to them.

# Put everything in /data/jetty and everything accessible at http://localhost:8081/myfile.json
docker run -dit --name httpd -p 8081:80 -v /data/jetty:/usr/local/apache2/htdocs/ httpd:2.4

To run (with Maven)

To run the server, run this task:

mvn jetty:run-war

This will start Jetty embedded on port 8080.

Access it at http://localhost:8080/

Run with Docker

docker build -t generate-java-swagger-api .

docker run -p 8080:8080 generate-java-swagger-api

Testing the server

Once started, you can navigate to http://localhost:8080/api/swagger.json to view the Swagger Resource Listing. This tells you that the server is up and ready to demonstrate Swagger.

Using the UI

There is an HTML5-based API tool bundled in this sample, you can view it it at http://localhost:8080. This lets you inspect the API using an interactive UI. You can access the source of this code from here

You can then open the dist/index.html file in any HTML5-enabled browser. Upen opening, enter the URL of your server in the top-centered input box (default is http://localhost:8080/api/swagger.json). Click the "Explore" button and you should see the resources available on the server.

Applying an API key

The sample app has an implementation of the Swagger ApiAuthorizationFilter. This restricts access to resources based on api-key. There are two keys defined in the sample app:

  • default-key
  • special-key

When no key is applied, the "default-key" is applied to all operations. If the "special-key" is entered, a number of other resources are shown in the UI, including sample CRUD operations.

Project built from https://github.com/tminglei/binder-swagger-java/tree/master/example/java-jaxrs

generate-java-swagger-api's People

Contributors

vemonet avatar

Watchers

Amrapali Zaveri avatar James Cloos avatar Michel Dumontier avatar Alexander Malic avatar  avatar Pedro V avatar

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.