Swagger for F# Web Apps

nlp-logo-navbarSwagger is a simple yet powerful representation of your RESTful API. With the largest ecosystem of API tooling on the planet, thousands of developers are supporting Swagger in almost every modern programming language and deployment environment. With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability.

Swagger is very powerful framework that is able to generate schema and rich UI for your RESTful API. As I know, Swagger is very popular framework especially in the non-.NET world. You probably have already seen Swagger UI (like this) at several resources.

It turns out that it is not hard to use Swagger for .NET F# apps. There is a project called Swashbuckle, which adds Swagger to WebApi projects.

First of all, you need to create F# ASP.NET Web API project. You can do it using “F# Web Application templates (MVC 5 and Web API 2.2) by Ryan Riley and Daniel Mohl“. Choose “Web API 2.2 and Katana 3.0” option in project creation wizard.

So, now you have F# Web App with RESTful API: CarsController with two services ‘/api/cars‘ and ‘/api/car/{id}‘. Everything is awesome but we do not have UI that is able to show a list of available services, their parameters and return types. Swashbuckle will help us here, we need to install ‘Swashbuckle.Core‘ package to our web app.

Install-Package Swashbuckle.Core

The last step is to update HttpConfiguration in Startup.fs in proper way to register Swagger. Add following three lines to the end of RegisterWebApi method.

open Swashbuckle.Application

type Startup() =
    static member RegisterWebApi(config: HttpConfiguration) =
        // ...
        // Swagger configuration
        config
          .EnableSwagger(fun c -> c.SingleApiVersion("v1", "My API") |> ignore)
          .EnableSwaggerUi();

That’s all! When you start your web application and open ‘/swagger/ui/index‘ URI you will see beautiful documentation for your RESTful API.
SwaggerUI

Real-time analytics with Apache Storm – now in F#

Eugene Tolmachev's avatarI think, therefore I spam.

Over the past several month I’ve been prototyping various aspects of  an IoT platform – or more specifically, exploring the concerns of “soft” real-time handling of communications with potentially hundreds of thousands of devices.

Up to this point, being in .NET ecosystem I’ve been building distributed solutions with a most excellent lightweight ESB – MassTransit, but for IoT we wanted to be a little closer to the wire. Starting with the clean slate and having discovered Apache Storm and Nathan’s presentation and I realized that it addresses exactly the challenges we have.

It appears to be the ultimate reactive microservices platform for lambda architecture: it is fairly simple, fault tolerant overall, yet embracing fire-n-forget and “let it fail” on the component level.

While Storm favours JDK for development, has extensive component support for Java developers and heavily optimizes for JRE components execution, it also supports “shell” components via its multilang protocol. Which is what, unlike Spark…

View original post 206 more words

F# Weekly #33, 2015

Welcome to F# Weekly,

Note that F# Weekly goes to summer holidays under the gentle Spanish sun. The next edition of F# Weekly will be published on the first of September.

A roundup of F# content from this past week:

News

Videos/Presentations

Blogs

F# vNext News

New releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #32Subscribe

F# Weekly #32, 2015

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

hack

Blogs

F# vNext News

New releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #31Subscribe

Building Azure Service Fabric Actors with F# – Part 1

Isaac Abraham's avatarThe Cockney Coder

This post is the first part of a brief overview of Service Fabric and how we can model Service Fabric Actors in F#. Part 1 will cover the details of how to get up and running in SF, whilst Part 2 will look at the challenges and solutions to modelling stateful actors in a OO-based framework within F#.

What is Service Fabric?

Service Fabric is a new service on Azure (currently in preview at the time of writing) which is designed to support reliable, scalable (at “hyper scale”) and maintainable distributed applications and services – with automatic support for things like replication of state across nodes, automatic failover & recovery and multi tenanting services on the same instances. It supports (currently) both stateful and stateless micro-services and actor model architectures (more on this shortly). The good thing about Service Fabric (SF) from a risk/reward point of view is that it’s…

View original post 1,228 more words

F# Weekly #31, 2015

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

Blogs

F# vNext News

New releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #30Subscribe

F# Weekly #30, 2015

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos

Blogs

F# vNext News

New releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #29Subscribe

F# Weekly #29, 2015

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

IC813371

Blogs

F# vNext News

New releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #28Subscribe

F# Weekly #28, 2015

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos/Presentations/Courses

Blogs

F# vNext News

New releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #27Subscribe