{"id":49098,"date":"2019-11-04T08:30:14","date_gmt":"2019-11-04T06:30:14","guid":{"rendered":"https:\/\/code-maze.com\/?p=49098"},"modified":"2024-04-04T18:01:35","modified_gmt":"2024-04-04T16:01:35","slug":"swagger-ui-asp-net-core-web-api","status":"publish","type":"post","link":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/","title":{"rendered":"Configuring and Using Swagger UI in ASP.NET Core Web API"},"content":{"rendered":"<p>In this article, we are going to learn how to integrate Swagger UI in an ASP.NET Core Web API application.\u00a0<\/p>\n<div style=\"padding: 20px; border-left: 5px color:#dc2323 solid; display: block; margin-bottom: 20px; box-shadow: 1px 1px 5px 0px lightgrey;\">To download the source code for the video, visit our <a href=\"https:\/\/www.patreon.com\/posts\/source-code-and-99786722?src=swagger\" target=\"_blank\" rel=\"nofollow noopener\">Patreon page<\/a> (YouTube Patron tier).<\/div>\n<p>Let&#8217;s dive in.<\/p>\n<hr \/>\r\n<p style=\"text-align: center;\"><strong>VIDEO<\/strong>: Implement SwaggerUI in the ASP.NET Core Web API Project.<\/p>\r\n<p style=\"text-align: center;\"><iframe width=\"560\" height=\"315\" src=https:\/\/www.youtube.com\/embed\/lml_j5ujjeQ?si=SdMioZlSFFejyY8h frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\r\n<hr \/>\n<h2><a id=\"TheNeed\"><\/a>Why We Should Document Our API<\/h2>\n<p>When developers consume APIs, they probably want to try and solve important business problems. Hence, it&#8217;s very important for them to understand how to use APIs effectively. This is where API documentation comes into play.<\/p>\n<p>API documentation is the process of giving instructions about how to use and integrate an API effectively. Thus, it can be thought of as a concise reference manual containing all the information required to work with an API, with details about the functions, classes, return types, arguments, and much more, supported by tutorials and examples.<\/p>\n<p><strong>So having the proper documentation for an API enables the consumers to integrate that API as quickly as possible<\/strong> and move forward with their development. Furthermore, this also helps them <strong>understand the value and usage of the API, improves the chances for API adoption, and makes APIs easier to maintain and support in general<\/strong>.<\/p>\n<h2><a id=\"SwaggerOpenAPI\"><\/a>Swagger\/OpenAPI<\/h2>\n<p>Okay, let\u2019s talk about a tool we\u2019re going to use to create API documentation.<\/p>\n<p>Swagger is a set of tools created by the company SmartBear to help us with the API production and documentation process. <strong>Although we still hear Swagger being referred to as OpenAPI, this is no longer true<\/strong>. OpenAPI refers to the industry-standard specification for RESTful API design.<\/p>\n<p><strong>In short, OpenAPI is an industry-standard specification for Restful APIs, and Swagger is composed of the tools used to implement OpenAPI.<\/strong><\/p>\n<p>Open source Swagger tools consist of:<\/p>\n<ul>\n<li>Swagger Editor<\/li>\n<li>Swagger Codegen<\/li>\n<li>Swagger UI<\/li>\n<\/ul>\n<p>In this tutorial, we\u2019re going to talk about configuring and using Swagger UI.<\/p>\n<p>Swagger UI offers a web-based interface that allows anyone to interact with the API without having to know the implementation. It\u2019s automatically generated from our OpenAPI specification and it allows for an easy documentation visualization.<\/p>\n<h2><a id=\"Integrating\"><\/a>Integrating Swagger UI into our Applications<\/h2>\n<p>We can use the Swashbuckle package to easily integrate Swagger into our .NET Core Web API projects. It will generate the Swagger specification for our project. Additionally, the Swagger UI is also contained within Swashbuckle.<\/p>\n<p>There are three main components in the Swashbuckle package:<\/p>\n<p><code>Swashbuckle.AspNetCore.Swagger<\/code>: This contains the Swagger object model and the middleware to expose SwaggerDocument objects as JSON.<\/p>\n<p><code>Swashbuckle.AspNetCore.SwaggerGen<\/code>: A Swagger generator that builds SwaggerDocument objects directly from our routes, controllers, and models.\u00a0<\/p>\n<p><code>Swashbuckle.AspNetCore.SwaggerUI<\/code>: An embedded version of the Swagger UI tool. It interprets Swagger JSON to build a rich, customizable experience for describing the web API functionality.<\/p>\n<h3><a id=\"Installing\"><\/a>Installing the Package<\/h3>\n<p>The first step is to install the Swashbuckle package.<\/p>\n<p>We can execute the following command in the Package Manager Console window:<\/p>\n<p><code>Install-Package Swashbuckle.AspNetCore -version 6.1.4<\/code><\/p>\n<p>This will install the Swashbuckle package in our application. You can upgrade the version on your end, but this article is compatible with version 6.1.4.<\/p>\n<h3><a id=\"Configuring\"><\/a>Configuring the Swagger Middleware<\/h3>\n<p>The next step is to configure the Swagger Middleware.<\/p>\n<p>Let\u2019s make the following changes in the <code>ConfigureServices()<\/code> method of the <code>Startup.cs<\/code> class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public void ConfigureServices(IServiceCollection services)\r\n{\r\n    \/\/ Register the Swagger generator, defining 1 or more Swagger documents\r\n    services.AddSwaggerGen(c =&gt;\r\n    {\r\n        c.SwaggerDoc(\"v1\", new OpenApiInfo { Title = \"My API\", Version = \"v1\" });                \r\n    });\r\n\r\n    services.AddControllers();\r\n}<\/pre>\n<p>As a result, this adds the Swagger generator to the services collection.<\/p>\n<p>In the <code>Configure()<\/code> method, let&#8217;s enable the middleware for serving the generated JSON document and the Swagger UI:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\r\n{\r\n    \/\/ Enable middleware to serve generated Swagger as a JSON endpoint.\r\n    app.UseSwagger();\r\n\r\n    \/\/ Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),\r\n    \/\/ specifying the Swagger JSON endpoint.\r\n    app.UseSwaggerUI(c =&gt;\r\n    {\r\n        c.SwaggerEndpoint(\"\/swagger\/v1\/swagger.json\", \"My API V1\");\r\n    });\r\n}<\/pre>\n<p>By executing these steps, the Swagger is configured and ready for use in our project.<\/p>\n<h3><a id=\"Exploring\"><\/a>Exploring the Swagger UI<\/h3>\n<p>First, we are going to create an <code>Employee<\/code> class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public class Employee\r\n{\r\n    public int Id { get; set; }\r\n\r\n    public string FirstName { get; set; }\r\n\r\n    public string LastName { get; set; }\r\n\r\n    public string EmailId { get; set; }\r\n}<\/pre>\n<p>Next, let&#8217;s create an API controller with action methods. We are going to use some mock data and keep the focus on understanding Swagger\u2019s capabilities:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">[Route(\"api\/[controller]\")]\r\n[ApiController]\r\npublic class EmployeeController : ControllerBase\r\n{\r\n    \/\/ GET: api\/Employee\r\n    [HttpGet]\r\n    public IEnumerable&lt;Employee&gt; Get()\r\n    {\r\n        return GetEmployees();\r\n    }\r\n\r\n    \/\/ GET: api\/Employee\/5\r\n    [HttpGet(\"{id}\", Name = \"Get\")]\r\n    public Employee Get(int id)\r\n    {\r\n        return GetEmployees().Find(e =&gt; e.Id == id);\r\n    }\r\n\r\n    \/\/ POST: api\/Employee\r\n    [HttpPost]\r\n    [Produces(\"application\/json\")]\r\n    public Employee Post([FromBody] Employee employee)\r\n    {\r\n        \/\/ Logic to create new Employee\r\n        return new Employee();\r\n    }\r\n\r\n    \/\/ PUT: api\/Employee\/5\r\n    [HttpPut(\"{id}\")]\r\n    public void Put(int id, [FromBody] Employee employee)\r\n    {\r\n        \/\/ Logic to update an Employee\r\n    }\r\n\r\n    \/\/ DELETE: api\/Employee\/5\r\n    [HttpDelete(\"{id}\")]\r\n    public void Delete(int id)\r\n    {\r\n    }\r\n    private List&lt;Employee&gt; GetEmployees()\r\n    {\r\n        return new List&lt;Employee&gt;()\r\n        {\r\n            new Employee()\r\n            {\r\n                Id = 1,\r\n                FirstName= \"John\",\r\n                LastName = \"Smith\",\r\n                EmailId =\"John.Smith@gmail.com\"\r\n            },\r\n            new Employee()\r\n            {\r\n                Id = 2,\r\n                FirstName= \"Jane\",\r\n                LastName = \"Doe\",\r\n                EmailId =\"Jane.Doe@gmail.com\"\r\n            }\r\n        };\r\n    }\r\n}<\/pre>\n<p>Now, let\u2019s run the app and navigate to <code>https:\/\/localhost:&lt;port&gt;\/swagger\/v1\/swagger.json<\/code>. We can see that a document describing the endpoints is generated:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-json.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49283 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-json.png\" alt=\"swagger-json\" width=\"680\" height=\"795\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-json.png 680w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-json-257x300.png 257w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>To inspect the Swagger UI, we can navigate to <code>https:\/\/localhost:&lt;port&gt;\/swagger<\/code>:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49284 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui.png\" alt=\"swagger-ui\" width=\"998\" height=\"1010\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui.png 998w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-296x300.png 296w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-768x777.png 768w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-75x75.png 75w\" sizes=\"auto, (max-width: 998px) 100vw, 998px\" \/><\/a><\/p>\n<p>Now we can explore the API via the Swagger UI and it will be easier to incorporate it into other applications. Furthermore, we can see each controller and its action methods.<\/p>\n<p>Once we click on an action method, we can see detailed information like parameters, response, and example values. There is also an option to try out each of those action methods:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-action-method.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49285 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-action-method.png\" alt=\"swagger-ui-action-method\" width=\"996\" height=\"968\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-action-method.png 996w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-action-method-300x292.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-action-method-768x746.png 768w\" sizes=\"auto, (max-width: 996px) 100vw, 996px\" \/><\/a><\/p>\n<p>By clicking on the &#8220;Try it out&#8221; button, we can test the endpoint and see the response:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-try-it-out.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49286 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-try-it-out.png\" alt=\"swagger-ui-try-it-out\" width=\"797\" height=\"988\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-try-it-out.png 797w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-try-it-out-242x300.png 242w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-try-it-out-768x952.png 768w\" sizes=\"auto, (max-width: 797px) 100vw, 797px\" \/><\/a><\/p>\n<h2><a id=\"Extending\"><\/a>Extending and Customizing\u00a0<\/h2>\n<p>Swagger provides options for extending the documentation and customizing the UI.<\/p>\n<h3><a id=\"ExtendingDocumentation\"><\/a>Extending the documentation<\/h3>\n<p>Let\u2019s look at the various options to extend the documentation.<\/p>\n<h4>API Info &amp; Description<\/h4>\n<p>First, let\u2019s see how we can specify the API info and description.<\/p>\n<p>The <code>configuration<\/code> action passed to the <code>AddSwaggerGen()<\/code> method adds information such as Contact, License, and Description. Let&#8217;s provide some values for those:<i>\u00a0<\/i><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\/\/ This method gets called by the runtime. Use this method to add services to the container.\r\npublic void ConfigureServices(IServiceCollection services)\r\n{\r\n    \/\/ Register the Swagger generator, defining 1 or more Swagger documents\r\n    services.AddSwaggerGen(c =&gt;\r\n    {\r\n        c.SwaggerDoc(\"v1\", new OpenApiInfo\r\n        {\r\n            Title = \"Employee API\",\r\n            Version = \"v1\",\r\n            Description = \"An API to perform Employee operations\",\r\n            TermsOfService = new Uri(\"https:\/\/example.com\/terms\"),\r\n            Contact = new OpenApiContact\r\n            {\r\n                Name = \"John Walkner\",\r\n                Email = \"John.Walkner@gmail.com\",\r\n                Url = new Uri(\"https:\/\/twitter.com\/jwalkner\"),\r\n            },\r\n            License = new OpenApiLicense\r\n            {\r\n                Name = \"Employee API LICX\",\r\n                Url = new Uri(\"https:\/\/example.com\/license\"),\r\n            }\r\n        });\r\n    });\r\n}<\/pre>\n<p><i><\/i>Now let\u2019s run the application once again and explore the Swagger UI:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-api-info.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49287 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-api-info.png\" alt=\"swagger-ui-api-info\" width=\"991\" height=\"877\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-api-info.png 991w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-api-info-300x265.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/swagger-ui-api-info-768x680.png 768w\" sizes=\"auto, (max-width: 991px) 100vw, 991px\" \/><\/a><\/p>\n<p>We can see that the Swagger document is now updated with API Info.<\/p>\n<h4>XML Comments<\/h4>\n<p>For enabling XML comments, we need to do the following steps:<\/p>\n<ol>\n<li>In the Build tab of the project properties, check the box labeled <code>XML documentation file<\/code>. Let\u2019s keep the auto-generated file path.<\/li>\n<li>Suppress warning 1591, which will now give warnings about any method, class, or field that doesn&#8217;t have triple-slash comments.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/generate-xml-documentation-setting.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49292 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/generate-xml-documentation-setting.png\" alt=\"generate-xml-documentation-setting\" width=\"1171\" height=\"786\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/generate-xml-documentation-setting.png 1171w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/generate-xml-documentation-setting-300x201.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/generate-xml-documentation-setting-768x515.png 768w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/generate-xml-documentation-setting-1024x687.png 1024w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/generate-xml-documentation-setting-1080x725.png 1080w\" sizes=\"auto, (max-width: 1171px) 100vw, 1171px\" \/><\/a><\/p>\n<p>In the <code>ConfigureServices()<\/code> method, configure Swagger to use the XML file that&#8217;s generated in the above step:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-highlight=\"25-28\">public void ConfigureServices(IServiceCollection services)\r\n{\r\n    \/\/ Register the Swagger generator, defining 1 or more Swagger documents\r\n    services.AddSwaggerGen(c =&gt;\r\n    {\r\n        c.SwaggerDoc(\"v1\", new OpenApiInfo\r\n        {\r\n            Title = \"Employee API\",\r\n            Version = \"v1\",\r\n            Description = \"An API to perform Employee operations\",\r\n            TermsOfService = new Uri(\"https:\/\/example.com\/terms\"),\r\n            Contact = new OpenApiContact\r\n            {\r\n                Name = \"John Walkner\",\r\n                Email = \"John.Walkner@gmail.com\",\r\n                Url = new Uri(\"https:\/\/twitter.com\/jwalkner\"),\r\n            },\r\n            License = new OpenApiLicense\r\n            {\r\n                Name = \"Employee API LICX\",\r\n                Url = new Uri(\"https:\/\/example.com\/license\"),\r\n            }\r\n        });\r\n\r\n        \/\/ Set the comments path for the Swagger JSON and UI.\r\n        var xmlFile = $\"{Assembly.GetExecutingAssembly().GetName().Name}.xml\";\r\n        var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);\r\n        c.IncludeXmlComments(xmlPath);\r\n    });\r\n\r\n    services.AddControllers();\r\n}<\/pre>\n<p>Now, adding triple-slash comments to the action method enhances the Swagger UI by adding a description to the section header.<\/p>\n<p>Let\u2019s add a summary:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\/\/\/ &lt;summary&gt;\r\n\/\/\/ Gets the list of all Employees.\r\n\/\/\/ &lt;\/summary&gt;\r\n\/\/\/ &lt;returns&gt;The list of Employees.&lt;\/returns&gt;\r\n\/\/ GET: api\/Employee\r\n[HttpGet]\r\npublic IEnumerable&lt;Employee&gt; Get()\r\n{\r\n    return GetEmployees();\r\n}<\/pre>\n<p>This displays the summary against the action method:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49288 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary.png\" alt=\"action-method-with-summary\" width=\"1001\" height=\"240\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary.png 1001w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary-300x72.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary-768x184.png 768w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/a><\/p>\n<p>We can additionally add <code>&lt;remarks&gt;<\/code> element to the documentation. It supplements information specified in the <code>&lt;summary&gt;<\/code> element and provides a more robust Swagger UI. The <code>&lt;remarks&gt;<\/code> element content can consist of text, JSON, or XML:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-highlight=\"4-13\">\/\/\/ &lt;summary&gt;\r\n\/\/\/ Creates an Employee.\r\n\/\/\/ &lt;\/summary&gt;\r\n\/\/\/ &lt;remarks&gt;\r\n\/\/\/ Sample request:\r\n\/\/\/ \r\n\/\/\/     POST api\/Employee\r\n\/\/\/     {        \r\n\/\/\/       \"firstName\": \"Mike\",\r\n\/\/\/       \"lastName\": \"Andrew\",\r\n\/\/\/       \"emailId\": \"Mike.Andrew@gmail.com\"        \r\n\/\/\/     }\r\n\/\/\/ &lt;\/remarks&gt;\r\n\/\/\/ &lt;param name=\"employee\"&gt;&lt;\/param&gt;        \r\n[HttpPost]\r\n[Produces(\"application\/json\")]\r\npublic Employee Post([FromBody] Employee employee)\r\n{\r\n    \/\/ Logic to create new Employee\r\n    return new Employee();\r\n}<\/pre>\n<p>This will enhance the UI with additional info:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary-and-remarks.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49289 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary-and-remarks.png\" alt=\"action-method-with-summary-and-remarks\" width=\"979\" height=\"343\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary-and-remarks.png 979w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary-and-remarks-300x105.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/action-method-with-summary-and-remarks-768x269.png 768w\" sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><\/a><\/p>\n<p>We&#8217;ve learned how to enhance the documentation using XML comments.<\/p>\n<h4>Using Data Annotations<\/h4>\n<p>We can decorate a model with attributes to enhance the documentation.<\/p>\n<p>Let\u2019s add a <code>[Required]<\/code> attribute to the <code>EmailId<\/code> field of the <code>Employee<\/code> model:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-highlight=\"9\">public class Employee\r\n{\r\n    public int Id { get; set; }\r\n\r\n    public string FirstName { get; set; }\r\n\r\n    public string LastName { get; set; }\r\n\r\n    [Required]\r\n    public string EmailId { get; set; }\r\n}<\/pre>\n<p>As a result, the Swagger UI will accept this change:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/required-attribute-in-swagger-ui.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49290 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/required-attribute-in-swagger-ui.png\" alt=\"required-attribute-in-swagger-ui\" width=\"934\" height=\"346\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/required-attribute-in-swagger-ui.png 934w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/required-attribute-in-swagger-ui-300x111.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/required-attribute-in-swagger-ui-768x285.png 768w\" sizes=\"auto, (max-width: 934px) 100vw, 934px\" \/><\/a><\/p>\n<h4>Describing Response Types<\/h4>\n<p>The developers who consume our APIs are usually more interested in what it returns- specifically the response types and error codes. Hence it is very important to describe our response types.\u00a0 These are denoted using XML comments &amp; data annotations.<\/p>\n<p>Let&#8217;s enhance the response types a little bit:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-highlight=\"16-17,19-20\">\/\/\/ &lt;summary&gt;\r\n\/\/\/ Creates an Employee.\r\n\/\/\/ &lt;\/summary&gt;\r\n\/\/\/ &lt;remarks&gt;\r\n\/\/\/ Sample request:\r\n\/\/\/ \r\n\/\/\/     POST api\/Employee\r\n\/\/\/     {        \r\n\/\/\/       \"firstName\": \"Mike\",\r\n\/\/\/       \"lastName\": \"Andrew\",\r\n\/\/\/       \"emailId\": \"Mike.Andrew@gmail.com\"        \r\n\/\/\/     }\r\n\/\/\/ &lt;\/remarks&gt;\r\n\/\/\/ &lt;param name=\"employee\"&gt;&lt;\/param&gt;\r\n\/\/\/ &lt;returns&gt;A newly created employee&lt;\/returns&gt;\r\n\/\/\/ &lt;response code=\"201\"&gt;Returns the newly created item&lt;\/response&gt;\r\n\/\/\/ &lt;response code=\"400\"&gt;If the item is null&lt;\/response&gt;          \r\n[HttpPost]\r\n[ProducesResponseType(201)]\r\n[ProducesResponseType(400)]\r\n[Produces(\"application\/json\")]\r\npublic Employee Post([FromBody] Employee employee)\r\n{\r\n    \/\/ Logic to create new Employee\r\n    return new Employee();\r\n}<\/pre>\n<p>This will reflect in the Responses section:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/repsonse-types.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49291 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/repsonse-types.png\" alt=\"repsonse-types\" width=\"952\" height=\"717\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/repsonse-types.png 952w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/repsonse-types-300x226.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/repsonse-types-768x578.png 768w\" sizes=\"auto, (max-width: 952px) 100vw, 952px\" \/><\/a><\/p>\n<p>In this section, we\u2019ve looked at various options for extending the documentation.<\/p>\n<h3><a id=\"CustomizingUI\"><\/a>Customizing the UI<\/h3>\n<p>The default UI of Swagger is pretty good. But we can customize it If we wish to do so. We may change the documentation pages to represent our brand or theme. Branding the Swagger components requires adding the resources to serve static files and building the folder structure to host those files.<\/p>\n<p>First of all, we are going to enable static file middleware in the <code>Configure()<\/code> method in the <code>Startup.cs<\/code> file:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">app.UseStaticFiles();<\/code><\/p>\n<p>After that, let\u2019s acquire the contents of the <code>dist<\/code> folder from the Swagger UI GitHub <a href=\"https:\/\/github.com\/swagger-api\/swagger-ui\/tree\/master\/dist\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">repository<\/a>. This folder contains the necessary assets for the Swagger UI page.<\/p>\n<p>Let\u2019s create a <code>wwwroot\/swagger\/ui<\/code> folder, and copy the contents of the dist folder into it.<\/p>\n<p>Additionally, let\u2019s create a <code>custom.css<\/code> file in <code>wwwroot\/swagger\/ui<\/code> with the following CSS to customize the page header:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"scss\">.swagger-ui .topbar {\r\n    background-color: grey;\r\n    border-bottom: 3px solid black;\r\n}<\/pre>\n<p>We have to reference <i>custom.css<\/i> in the <code>index.html<\/code> file inside UI folder, after any other CSS files:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\".\/swagger-ui.css\"&gt;\r\n&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"custom.css\"&gt;<\/pre>\n<p>Finally, let\u2019s browse to the <code>index.html<\/code> page at <code>https:\/\/localhost:&lt;port&gt;\/swagger\/ui\/index.html<\/code>, enter <code>https:\/\/localhost:&lt;port&gt;\/swagger\/v1\/swagger.json<\/code> in the header&#8217;s textbox, and click the Explore button.\u00a0<\/p>\n<p>We can see that the UI is now customized with the changes we made:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/customized-ui.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-49294 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/customized-ui.png\" alt=\"customized-ui\" width=\"979\" height=\"550\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/customized-ui.png 979w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/customized-ui-300x169.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/10\/customized-ui-768x431.png 768w\" sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><\/a><\/p>\n<p>At this point, we are familiar with different options for customizing the Swagger UI.<\/p>\n<h2>Conclusion<\/h2>\n<p>We have looked at the following topics in this article:<\/p>\n<ul>\n<li>The need for documenting our APIs<\/li>\n<li>Swagger\/OpenAPI &#8211; Swagger Specification &amp; Swagger UI<\/li>\n<li>Integrating Swagger UI into an ASP.NET Core Web API<\/li>\n<li>Extending the Swagger Documentation<\/li>\n<li>Customizing the Swagger UI<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to learn how to integrate Swagger UI in an ASP.NET Core Web API application.\u00a0 Let&#8217;s dive in. Why We Should Document Our API When developers consume APIs, they probably want to try and solve important business problems. Hence, it&#8217;s very important for them to understand how to use APIs [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":54933,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[12,2079],"tags":[22,9,79,601,602,8,47,600],"class_list":["post-49098","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-csharp","category-web-api","tag-net-core","tag-api","tag-asp-net-core","tag-documentation","tag-documenting","tag-rest","tag-rest-api","tag-swagger","et-has-post-format-content","et_post_format-et-post-format-standard"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Configuring and Using Swagger UI in ASP.NET Core Web API - Code Maze<\/title>\n<meta name=\"description\" content=\"We are going to learn how to integrate the Swagger UI\/OpenAPI in an ASP.NET Core Web API, extend the documentation, and customize UI.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Configuring and Using Swagger UI in ASP.NET Core Web API - Code Maze\" \/>\n<meta property=\"og:description\" content=\"We are going to learn how to integrate the Swagger UI\/OpenAPI in an ASP.NET Core Web API, extend the documentation, and customize UI.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/\" \/>\n<meta property=\"og:site_name\" content=\"Code Maze\" \/>\n<meta property=\"article:published_time\" content=\"2019-11-04T06:30:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-04T16:01:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"620\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Code Maze\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/CodeMazeBlog\" \/>\n<meta name=\"twitter:site\" content=\"@CodeMazeBlog\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Code Maze\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/\"},\"author\":{\"name\":\"Code Maze\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04\"},\"headline\":\"Configuring and Using Swagger UI in ASP.NET Core Web API\",\"datePublished\":\"2019-11-04T06:30:14+00:00\",\"dateModified\":\"2024-04-04T16:01:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/\"},\"wordCount\":1330,\"commentCount\":44,\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png\",\"keywords\":[\".NET CORE\",\"API\",\"asp.net core\",\"documentation\",\"documenting\",\"REST\",\"REST API\",\"swagger\"],\"articleSection\":[\"C#\",\"Web API\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/\",\"url\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/\",\"name\":\"Configuring and Using Swagger UI in ASP.NET Core Web API - Code Maze\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png\",\"datePublished\":\"2019-11-04T06:30:14+00:00\",\"dateModified\":\"2024-04-04T16:01:35+00:00\",\"description\":\"We are going to learn how to integrate the Swagger UI\/OpenAPI in an ASP.NET Core Web API, extend the documentation, and customize UI.\",\"breadcrumb\":{\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#primaryimage\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png\",\"width\":1100,\"height\":620,\"caption\":\"swagger ui asp net core\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/code-maze.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Configuring and Using Swagger UI in ASP.NET Core Web API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/code-maze.com\/#website\",\"url\":\"https:\/\/code-maze.com\/\",\"name\":\"Code Maze\",\"description\":\"Learn. Code. Succeed.\",\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/code-maze.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/code-maze.com\/#organization\",\"name\":\"Code Maze\",\"url\":\"https:\/\/code-maze.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"width\":3511,\"height\":3510,\"caption\":\"Code Maze\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/CodeMazeBlog\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04\",\"name\":\"Code Maze\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png\",\"caption\":\"Code Maze\"},\"description\":\"This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/codemaze\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog\"],\"url\":\"https:\/\/code-maze.com\/author\/codemazecontributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Configuring and Using Swagger UI in ASP.NET Core Web API - Code Maze","description":"We are going to learn how to integrate the Swagger UI\/OpenAPI in an ASP.NET Core Web API, extend the documentation, and customize UI.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/","og_locale":"en_US","og_type":"article","og_title":"Configuring and Using Swagger UI in ASP.NET Core Web API - Code Maze","og_description":"We are going to learn how to integrate the Swagger UI\/OpenAPI in an ASP.NET Core Web API, extend the documentation, and customize UI.","og_url":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/","og_site_name":"Code Maze","article_published_time":"2019-11-04T06:30:14+00:00","article_modified_time":"2024-04-04T16:01:35+00:00","og_image":[{"width":1100,"height":620,"url":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png","type":"image\/png"}],"author":"Code Maze","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/CodeMazeBlog","twitter_site":"@CodeMazeBlog","twitter_misc":{"Written by":"Code Maze","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#article","isPartOf":{"@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/"},"author":{"name":"Code Maze","@id":"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04"},"headline":"Configuring and Using Swagger UI in ASP.NET Core Web API","datePublished":"2019-11-04T06:30:14+00:00","dateModified":"2024-04-04T16:01:35+00:00","mainEntityOfPage":{"@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/"},"wordCount":1330,"commentCount":44,"publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"image":{"@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png","keywords":[".NET CORE","API","asp.net core","documentation","documenting","REST","REST API","swagger"],"articleSection":["C#","Web API"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/","url":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/","name":"Configuring and Using Swagger UI in ASP.NET Core Web API - Code Maze","isPartOf":{"@id":"https:\/\/code-maze.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#primaryimage"},"image":{"@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png","datePublished":"2019-11-04T06:30:14+00:00","dateModified":"2024-04-04T16:01:35+00:00","description":"We are going to learn how to integrate the Swagger UI\/OpenAPI in an ASP.NET Core Web API, extend the documentation, and customize UI.","breadcrumb":{"@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#primaryimage","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/11\/swagger-ui-asp-net-core-1.png","width":1100,"height":620,"caption":"swagger ui asp net core"},{"@type":"BreadcrumbList","@id":"https:\/\/code-maze.com\/swagger-ui-asp-net-core-web-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code-maze.com\/"},{"@type":"ListItem","position":2,"name":"Configuring and Using Swagger UI in ASP.NET Core Web API"}]},{"@type":"WebSite","@id":"https:\/\/code-maze.com\/#website","url":"https:\/\/code-maze.com\/","name":"Code Maze","description":"Learn. Code. Succeed.","publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code-maze.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/code-maze.com\/#organization","name":"Code Maze","url":"https:\/\/code-maze.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","width":3511,"height":3510,"caption":"Code Maze"},"image":{"@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/CodeMazeBlog"]},{"@type":"Person","@id":"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04","name":"Code Maze","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/person\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png","caption":"Code Maze"},"description":"This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.","sameAs":["https:\/\/www.linkedin.com\/company\/codemaze\/","https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog"],"url":"https:\/\/code-maze.com\/author\/codemazecontributor\/"}]}},"_links":{"self":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/49098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/comments?post=49098"}],"version-history":[{"count":19,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/49098\/revisions"}],"predecessor-version":[{"id":63318,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/49098\/revisions\/63318"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media\/54933"}],"wp:attachment":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media?parent=49098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/categories?post=49098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/tags?post=49098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}