{"id":4314,"date":"2021-05-24T06:56:34","date_gmt":"2021-05-24T06:56:34","guid":{"rendered":"https:\/\/codethataint.com\/blog\/?p=4314"},"modified":"2021-05-24T11:55:12","modified_gmt":"2021-05-24T11:55:12","slug":"notes-on-swagger","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/notes-on-swagger\/","title":{"rendered":"Notes on Swagger"},"content":{"rendered":"<p><strong>Swagger Consist of Three Parts<\/strong><\/p>\n<ol>\n<li><strong>swagger-editor<\/strong>&#8211; Helps in editing yml file as per Open API Specification<\/li>\n<li><strong>swagger-ui<\/strong>&#8211; dist folder helps in circulating API documentation<\/li>\n<li><strong>swagger-codegen<\/strong><\/li>\n<\/ol>\n<p><strong>Installing Swagger in Local<\/strong><br \/>\nSwagger needs http-server. We would use node http-server. We should navigate to the swagger editor folder and start the http-server.<\/p>\n<pre>\r\n>>npm install -g http-server\r\n>>npm install\r\n>>http-server swagger-editor -a 127.0.0.1 -p 8090\r\n>>http-server swagger-ui -a 127.0.0.1 -p 8091\r\n<\/pre>\n<p>For the API Documentation we can copy and ship the <strong>dist<\/strong> folder in <strong>swagger-ui folder<\/strong>. We would have already placed the yaml file which we have created in <strong>swagger-editor<\/strong> in <strong>swagger-ui folder<\/strong>. Now we should edit the<strong> index.html <\/strong>file in swagger-ui folder as below to point to out yml file <\/p>\n<p><strong>index.html<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n.\r\n.\r\nwindow.onload = function() {\r\n  \/\/ Begin Swagger UI call region\r\n  const ui = SwaggerUIBundle({\r\n  url: &quot;EmpMgmt.yaml&quot;,\r\n  dom_id: '#swagger-ui',\r\n   deepLinking: true,\r\n.\r\n.\r\n<\/pre>\n<p>Presuming the project has Documentation in <strong>api-docs<\/strong> folder we can now start the server as below<\/p>\n<pre>\r\n>>D:\\Projects\\workspace\\EmpMgmt> http-server api-docs -a 127.0.0.1 -p 8091\r\n<\/pre>\n<p><em>Refernce for OpenAPI Specification<\/em><br \/>\n<a href=\"https:\/\/github.com\/OAI\/OpenAPI-Specification\/tree\/main\/versions\">https:\/\/github.com\/OAI\/OpenAPI-Specification\/tree\/main\/versions<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Swagger Consist of Three Parts swagger-editor&#8211; Helps in editing yml file as per Open API Specification swagger-ui&#8211; dist folder helps in circulating API documentation swagger-codegen Installing Swagger in Local Swagger needs http-server. We would use node http-server. We should navigate to the swagger editor folder and start the http-server. >>npm install -g http-server >>npm install&hellip; <a href=\"https:\/\/codethataint.com\/blog\/notes-on-swagger\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[322],"tags":[],"class_list":["post-4314","post","type-post","status-publish","format-standard","hentry","category-openapi"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/4314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=4314"}],"version-history":[{"count":5,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/4314\/revisions"}],"predecessor-version":[{"id":4320,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/4314\/revisions\/4320"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=4314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=4314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=4314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}