Best practices for ABP integrated swagger

Source: Internet
Author: User

1. Add NuGet packages to your project Abp.Web.Api.SwaggerTool

2. Add Abpwebapiswaggertoolmodule to the DependsOn of the project ABP module

Run it, launch the project, Access/swagger/ui/index to open the familiar Swagger-ui interface, and the interfaces for Webapi and dynamic APIs appear in the project.

Abp.Web.Api.SwaggerTool, as a swagger enhancement package, implements many useful features internally and provides some best practices that users don't care about swagger integration issues.

Project source code Https://github.com/yuzukwok/Abp.Web.Api.SwaggerTool We can put forward issue or fork

V0.1.1

function Introduction

1. Remote Agent Generation

We can generate remote agents that access these APIs based on the API meta-information described in the swagger documentation, currently supporting CSharp Webapiclient,jquery or Angularjs code.

The user accesses the following endpoint to obtain the code for the agent

/swagger/proxy/csharp
/swagger/proxy/jquerycallbacks
/swagger/proxy/jquerypromises
/swagger/proxy/angularjs
/swagger/proxy/angular2

2. Convert swagger document to postman supported import format, which is more versatile than Postman's own import function

Access point:/swagger/postman

Categorized by folder, supports Chinese annotations, and the Post interface automatically generates sample data

3. Can search the interface directly on the SWAGGER-UI, currently only support search API address

/swagger/docs/{apiversion}/{key to search by path}

4.6 Kinds of swagger-ui style, get rid of the default Swagger-ui

Https://github.com/ostranme/swagger-ui-themes

5. Enhanced Swashbuckle: Optimize enumeration display, automatically use the Display feature text, Webapicontroller class on the DisplayName feature can display the controller's comments on Swagger-ui

Configuration file Description

The class library uses LTS. Configuation as a profile convention, no configuration file is required by default

In the site root configuration. config folder, create a new Swaggertoolsettings.json file with the following file contents

{  "Enable":true,//whether to enable swagger integration"Theme": "Flattop",//Topic name Flattop,muted,newspaper,outline,monokai,feeling-blue"Csharpgen": {    "ClassName": "Apiclient",//class name generated by C # proxy"Namespace": "Apiservices"//C # Proxy-generated namespaces  },  "Typescriptgen": {    "ClassName": "Client",//the class name generated by the JS proxy"Namespace": "Apiservices"//the namespace generated by the JS proxy  },  "Postmangen": {    "Name": "Apiservices"//name  },  "Xmlcommentfiles": ["Xxx.xml"]//the file name of the XML comment}

Best practices for ABP integrated swagger

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.