Making Swashbuckle use custom YAML files in an ASP.NET Web API? - asp.net-web-api

I have a web API created in ASP.NET (.NET 4.6.2) and I need to implement Swagger UI into it.
Unfortunately, the API is created in such a way that it works with query parameters and method overloading, which both pose a significant problem to the auto-generated Swagger UI. Rather than go through the fairly complicated process of ResolveConflictingActions and/or using XML documentation to unknown effect, I would much prefer writing up a custom YAML file and have my project use that. However, so far, I have not been able to find a way to make Swashbuckle accept a custom one.
Tried adding the YAML file as a custom asset in SwaggerConfig.cs
The project seems to have accepted the file - no build errors, the UI reports no errors either but still uses the autogenerated structure.

Related

Atlaskit Editor Core with custom mention provider

I’m trying to implement a custom mention provider to the Editor Core unsuccessful because I had not found any documentation and/or example how to do it.
Any1 has a reference or real example about it? I want to use the mention plugin on the editor core without making an api call, just want to load the list of participants that are already load before.

How to auto generate the yaml code for api documentation in swagger editor?

I want to design my web api using swagger, but the problem is I have to write all the yaml code myself, which in itself is a time consuming and tedious process. Can this process be automated?
I tried searching but did not anything useful.
Is auto-generation of yaml code for api design even possible before creating the api itself.
If yaml code can't be generated automatically then why use swagger for api design.
Any help will be appreciated. Thanks!
You can use swashbuckle instead of swagger (or alongside it, but i suggest just picking one)
https://github.com/domaindrivendev/Swashbuckle.AspNetCore#getting-started
They changed the docs since i've used it, however there's this tool you can use that scans your asp.net core project, looks at all controllers and routes and generates an opeapi document for you.
It can also generate client code and a bunch of other things.

Automatically generate TypeScript client code for ASP.NET Core controllers

I'm searching for a way to automatically generate the TypesScript client code from a ASP.NET Core Web-Application (Currently using Visual Studio 2017RC and webpack).
Are there any existing tools to generate the TypeScript client either in the build pipeline from visual studio or with webpack? I tried to use swagger middleware and then generate to client from the swagger URL, but I'm not sure if the intermediate swagger generation is the right tool for the job. Also the disconnectedness from the build tools is not ideal.
Both NSwag and Swashbuckle/swagger-codegen are awesome.
Typewriter is another awesome option.
So, here is how I would take the decision:
Need to generate TypeScript Models as per the C# models, go for TypeWriter
Need to generate complete client side code with command line that you can add as a build or publish step go for Swagger Code Gen
Need to play with the generated Swagger Spec or Generated Code to add your customizations - go for NSwag
Need to show Client inline code snippets in Swagger UI, use SwaggerUI-snippets
You can add Swashbuckle to your ASP.NET Core webapp and then generate Swagger/OpenAPI spec.
With the Swagger/OpenAPI spec, you can then use Swagger Codegen to generate not only TypeScript API clients (Node, Angular, Angular2, Fetch), but also API clients in C#, Java, JS, Swift, etc as well as API documentation.
The easiest way to try Swagger Codegen is to use https://editor.swagger.io by importing your spec and then select the target API client/server you want to generate. (https://editor.swagger.io leverages https://generator.swagger.io to generate code and generator.swagger.io is powered by Swagger Codegen)
Swagger Codegen can also generate server stubs in C# Nancyfx or ASP.NET core so you may consider following the contract-first approach by writing the spec using https://editor.swagger.io and then generating both API clients and server stubs.
UPDATE: On May 2018, about 50 top contributors and template creators of Swagger Codegen decided to fork Swagger Codegen to maintain a community-driven version called OpenAPI Generator. Please refer to the Q&A for more information.
Another option is NSwag which can generate Swagger specs from your ASP.NET (Core) controllers and TypeScript clients from this Swagger spec (for Angular, AngularJS, Fetch, etc.). The integration is very simple and it supports many advanced features (inheritance, named enums, code extensions, etc).
http://NSwag.org
Using the NSwagStudio UI it is very simple to get started and then you can automate everything with NPM package (i.e. running the config file in the cmd line).
I'm one of the authors of the project.
If you need to generate DTOs and API clients, then your options are
NSwag. The most popular tool for the job. But it generates everything in one file that makes it hard to maintain/debug.
Swagger Codegen or its fork with more features OpenAPI Generator. A Java-based option producing separate files, but with limited customisation.
AutoRest. A npm solution for packing up API clients in npm packages.
WebApiClientGen. A solution mentioned by the author below in this thread.
TypeWriter. VS extension, where you can craft your own implementation.
If you need DTOs only, then I'd look towards
Reinforced.Typings
TypeGen
More on these tools in this post - 6+ ways to marry C# with TypeScript.
You can also take a look at autorest.typescript client code generator. It provides good interfaces for all the model definitions, accurately defines readonly properties and enums. It supports a bunch of custom extensions that can be useful to improve the user experience of the generated client. You can take a look at some generated sample clients.
Bonus: The generated typescript client works in node.js and also in the browser.
If your TypeScript clients are with jQuery or Angular 2+, an alternative ASP.NET Web API Client Generators may be more handy, less overhead than swagger toolchain during SDLC.
And it supports .NET Core in addition to .NET Framework and .NET Standard.
Yet another option where you have full control over generated code is NTypewriter, which is basically Typewriter clone, but it uses Scriban syntax for templates.

Jetbrains REST API to move projects

I am trying to use the TeamCity REST API of JetBrains as shown in http://confluence.jetbrains.com/display/TCD8/REST+API
I was specifically looking for a way to "Move" projects between project hierarchies. Obviously you can use the web user interface to Move a project however I need to automate this.
The REST API only talks about adding build steps, agents and so on. Is there a specific API to move a job? I tried using the Chrome Developer tools to see what happens when you move the project in a web UI but could not detect anything.
The application.wadl has methods to do most of these although the confluence page itself does not necessarily document every single feature.
To achieve this project move between different hierarchies, you had to do a PUT request to
http://$host/guestAuth/app/rest/projects/id:$project_to_edit/parentProject
with a JSON snippet (or an XML) of the form
{"id" : $new_parent_id}

MVC sitemap provider & css styling

Does anyone know how to customise the rendering of the MVC sitemap provider so my ul element has a specific css class?
Try MvcSiteMapProvider hosted on CodePlex. You should be able to fairly easily migrate your existing Sitemap file to the slightly different but essentially compatible format. This will give you the ability to output your sitemap using the simple Html.MvcSiteMap().SiteMap() helper method.
The source of the project includes the default templates which you can edit to produce any rendering you like...or just pass in the name of a template in accordance with MVC convention. The model types you'll be rendering are SiteMapHelperModel, SiteMapNodeModel and SiteMapNodeModelList (namespaces removed for terseness).
I appreciate this may not be exactly what you're after as it relies on a 3rd party tool but its a useful project that supports much more than just rendering sitemaps. You'll want version 3.0.0 for MVC3.
Dan

Resources