Coder Social home page Coder Social logo

mdabbagh88 / fubumvc-swagger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kevm/fubumvc-swagger

0.0 1.0 0.0 565 KB

FubuMVC convention for creating API documentation for your content negotiation enabled actions

Home Page: http://fubuswagger.apphb.com/

License: Other

Ruby 2.96% C# 44.66% JavaScript 16.41% CSS 30.35% HTML 5.62%

fubumvc-swagger's Introduction

FubuMVC Swagger

This project helps your FubuMVC web application generate API documentation via Swagger.

swagger demo

See our Hello Swagger live demo.

How do I get it?

We have a nuget package available.

PM> Install-Package FubuMVC.Swagger

Building Swagger

To build just run rake grabbing the albacore gem if you don't already have it.

gem install albacore
rake

How do I put this in my peanut butter?

Note: This should all be simplified when I find the time to figure out Fubu Bottles.

Your API documented should support content negitiation and be grouped under the route /api. Take a look at the HelloSwagger for examples.

Checklist

Add a reference to this project. Why not use nuget!

Add the following to your FubuRegistry:

ApplyConvention<SwaggerConvention>();
Services(s=> s.AddService<IActionGrouper, APIRouteGrouper>());

Copy the swagger-ui directory into your /content direcotry.

Launch your web app and take a look at the /api to see if it is working.

What does this convention do?

Three routes will be added to your application:

GET /api

This route serves up the Swagger-UI page currently embedded into FubuSwagger. This part needs work.

GET /api/resources.json

Swagger UI does some resource discovery and uses the output of this route to find all of the API groups in your project.

GET /api/{GroupKey}.json

Details of each API group present in your app.

Pointing a Swagger UI web site at http://localhost:port/api/ should render pretty API documentation for your web application.

Why do I not see documentation for my actions?

Make sure the actions you wish to document are enabled for "Conneg"

In this example I have two marker interfaces which are used to mark input models on actions which will be APIs.

graph.Behaviors
 .Where(x => x.InputType().CanBeCastTo<IApi>() || x.InputType().CanBeCastTo<IUnauthenticatedApi>())
 .Each(x => x.MakeAsymmetricJson());

This example will force the result of these actions to be JSON. Note: This configuration is working around a bug in FubuMVC where normal browser usage will return XML for Conneg enabled endpoints. :(

Better yet take a look at the HelloSwagger demo application and see how it is wired up and organized.

How do I add more detail to my APIs

You can use data annotations to mark up your input models and their properties.

[Description("Workflow object history")]
public class HistoryRequest : IApi 
{
    [Required, Description("Type of workflow object. Typically this is 'case'.")]
    [AllowableValues("case", "subcase", "solution", "<any workflow object name>")]
    public string Type { get; set; }
    [Required, Description("Id of the workflow object.")]
    public string Id { get; set; }

    [Description("Limit the amout of history returned the given number of days. When this parameter is not specified. All history items will be returned.")]
	public int DaysOfHistory { get; set; }
}

fubumvc-swagger's People

Contributors

kevm avatar

Watchers

James Cloos 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.