{"id":73094,"date":"2026-02-07T01:25:22","date_gmt":"2026-02-06T17:25:22","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/73094.html"},"modified":"2026-02-07T01:25:22","modified_gmt":"2026-02-06T17:25:22","slug":"%e5%a4%9a%e8%af%ad%e8%a8%80%e6%94%af%e6%8c%81%e7%9a%84-net-core-api%e6%96%87%e6%a1%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/73094.html","title":{"rendered":"\u591a\u8bed\u8a00\u652f\u6301\u7684.NET Core API\u6587\u6863"},"content":{"rendered":"<p>\u5728\u73b0\u4ee3Web\u5f00\u53d1\u4e2d\uff0cAPI\u6587\u6863\u7684\u591a\u8bed\u8a00\u652f\u6301\u5df2\u7ecf\u6210\u4e3a\u4e00\u4e2a\u91cd\u8981\u9700\u6c42\u3002\u7279\u522b\u662f\u5bf9\u4e8e\u90a3\u4e9b\u9762\u5411\u5168\u7403\u7528\u6237\u7684\u5e94\u7528\u7a0b\u5e8f\u6765\u8bf4\uff0c\u63d0\u4f9b\u591a\u8bed\u8a00\u7684API\u6587\u6863\u4e0d\u4ec5\u63d0\u5347\u4e86\u7528\u6237\u4f53\u9a8c\uff0c\u8fd8\u80fd\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u5feb\u5730\u7406\u89e3\u548c\u4f7f\u7528API\u3002\u4eca\u5929\u6211\u4eec\u6765\u63a2\u8ba8\u5982\u4f55\u5728.NET Core Web API\u4e2d\u4f7f\u7528Swagger\uff08OpenAPI\uff09\u5b9e\u73b0\u591a\u8bed\u8a00\u652f\u6301\u3002<\/p>\n<h4>\u80cc\u666f\u4ecb\u7ecd<\/h4>\n<p>\u5728.NET Core\u4e2d\uff0cSwagger\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u751f\u6210RESTful API\u7684\u4ea4\u4e92\u5f0f\u6587\u6863\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cSwagger\u6587\u6863\u662f\u82f1\u6587\u7684\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e9b\u914d\u7f6e\u548c\u81ea\u5b9a\u4e49\u6765\u5b9e\u73b0\u591a\u8bed\u8a00\u652f\u6301\u3002<\/p>\n<h4>\u5b9e\u73b0\u591a\u8bed\u8a00Swagger\u6587\u6863<\/h4>\n<h5>1. \u751f\u6210\u591a\u8bed\u8a00Swagger\u6587\u6863<\/h5>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728Startup.cs\u4e2d\u914d\u7f6eSwagger\u751f\u6210\u5668\uff0c\u4e3a\u4e0d\u540c\u7684\u8bed\u8a00\u751f\u6210\u72ec\u7acb\u7684\u6587\u6863\uff1a<\/p>\n<p>services<span class=\"token punctuation\">.<\/span><span class=\"token function\">AddSwaggerGen<\/span><span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">=&gt;<\/span><br \/>\n<span class=\"token punctuation\">{<\/p>\n<p>   <\/span><br \/>\n    c<span class=\"token punctuation\">.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u73b0\u4ee3Web\u5f00\u53d1\u4e2d\uff0cAPI\u6587\u6863\u7684\u591a\u8bed\u8a00\u652f\u6301\u5df2\u7ecf\u6210\u4e3a\u4e00\u4e2a\u91cd\u8981\u9700\u6c42\u3002\u7279\u522b\u662f\u5bf9\u4e8e\u90a3\u4e9b\u9762\u5411\u5168\u7403\u7528\u6237\u7684\u5e94\u7528\u7a0b\u5e8f\u6765\u8bf4\uff0c\u63d0\u4f9b\u591a\u8bed\u8a00\u7684API\u6587\u6863\u4e0d\u4ec5\u63d0\u5347\u4e86\u7528\u6237\u4f53\u9a8c\uff0c\u8fd8\u80fd\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u5feb\u5730\u7406\u89e3\u548c\u4f7f\u7528API\u3002\u4eca\u5929\u6211\u4eec\u6765\u63a2\u8ba8\u5982\u4f55\u5728.NET Core Web API\u4e2d\u4f7f\u7528Swagger\uff08OpenAPI\uff09\u5b9e\u73b0\u591a\u8bed\u8a00\u652f\u6301\u3002<br \/>\n\u80cc\u666f\u4ecb\u7ecd<br \/>\n\u5728.NET Core\u4e2d\uff0cSwagger\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u751f\u6210RESTful API\u7684\u4ea4\u4e92\u5f0f\u6587\u6863\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cSwagger\u6587\u6863\u662f\u82f1\u6587\u7684\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e9b\u914d\u7f6e\u548c\u81ea<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[893,569],"topic":[],"class_list":["post-73094","post","type-post","status-publish","format-standard","hentry","category-server","tag-netcore","tag-569"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u591a\u8bed\u8a00\u652f\u6301\u7684.NET Core API\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/73094.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u591a\u8bed\u8a00\u652f\u6301\u7684.NET Core API\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5728\u73b0\u4ee3Web\u5f00\u53d1\u4e2d\uff0cAPI\u6587\u6863\u7684\u591a\u8bed\u8a00\u652f\u6301\u5df2\u7ecf\u6210\u4e3a\u4e00\u4e2a\u91cd\u8981\u9700\u6c42\u3002\u7279\u522b\u662f\u5bf9\u4e8e\u90a3\u4e9b\u9762\u5411\u5168\u7403\u7528\u6237\u7684\u5e94\u7528\u7a0b\u5e8f\u6765\u8bf4\uff0c\u63d0\u4f9b\u591a\u8bed\u8a00\u7684API\u6587\u6863\u4e0d\u4ec5\u63d0\u5347\u4e86\u7528\u6237\u4f53\u9a8c\uff0c\u8fd8\u80fd\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u5feb\u5730\u7406\u89e3\u548c\u4f7f\u7528API\u3002\u4eca\u5929\u6211\u4eec\u6765\u63a2\u8ba8\u5982\u4f55\u5728.NET Core Web API\u4e2d\u4f7f\u7528Swagger\uff08OpenAPI\uff09\u5b9e\u73b0\u591a\u8bed\u8a00\u652f\u6301\u3002 \u80cc\u666f\u4ecb\u7ecd \u5728.NET Core\u4e2d\uff0cSwagger\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u751f\u6210RESTful API\u7684\u4ea4\u4e92\u5f0f\u6587\u6863\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cSwagger\u6587\u6863\u662f\u82f1\u6587\u7684\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e9b\u914d\u7f6e\u548c\u81ea\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/73094.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-06T17:25:22+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/73094.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/73094.html\",\"name\":\"\u591a\u8bed\u8a00\u652f\u6301\u7684.NET Core API\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-06T17:25:22+00:00\",\"dateModified\":\"2026-02-06T17:25:22+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/73094.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/73094.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/73094.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u591a\u8bed\u8a00\u652f\u6301\u7684.NET Core API\u6587\u6863\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u591a\u8bed\u8a00\u652f\u6301\u7684.NET Core API\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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:\/\/www.wsisp.com\/helps\/73094.html","og_locale":"zh_CN","og_type":"article","og_title":"\u591a\u8bed\u8a00\u652f\u6301\u7684.NET Core API\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5728\u73b0\u4ee3Web\u5f00\u53d1\u4e2d\uff0cAPI\u6587\u6863\u7684\u591a\u8bed\u8a00\u652f\u6301\u5df2\u7ecf\u6210\u4e3a\u4e00\u4e2a\u91cd\u8981\u9700\u6c42\u3002\u7279\u522b\u662f\u5bf9\u4e8e\u90a3\u4e9b\u9762\u5411\u5168\u7403\u7528\u6237\u7684\u5e94\u7528\u7a0b\u5e8f\u6765\u8bf4\uff0c\u63d0\u4f9b\u591a\u8bed\u8a00\u7684API\u6587\u6863\u4e0d\u4ec5\u63d0\u5347\u4e86\u7528\u6237\u4f53\u9a8c\uff0c\u8fd8\u80fd\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u5feb\u5730\u7406\u89e3\u548c\u4f7f\u7528API\u3002\u4eca\u5929\u6211\u4eec\u6765\u63a2\u8ba8\u5982\u4f55\u5728.NET Core Web API\u4e2d\u4f7f\u7528Swagger\uff08OpenAPI\uff09\u5b9e\u73b0\u591a\u8bed\u8a00\u652f\u6301\u3002 \u80cc\u666f\u4ecb\u7ecd \u5728.NET Core\u4e2d\uff0cSwagger\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u751f\u6210RESTful API\u7684\u4ea4\u4e92\u5f0f\u6587\u6863\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cSwagger\u6587\u6863\u662f\u82f1\u6587\u7684\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e9b\u914d\u7f6e\u548c\u81ea","og_url":"https:\/\/www.wsisp.com\/helps\/73094.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-06T17:25:22+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/73094.html","url":"https:\/\/www.wsisp.com\/helps\/73094.html","name":"\u591a\u8bed\u8a00\u652f\u6301\u7684.NET Core API\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-06T17:25:22+00:00","dateModified":"2026-02-06T17:25:22+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/73094.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/73094.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/73094.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u591a\u8bed\u8a00\u652f\u6301\u7684.NET Core API\u6587\u6863"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/73094","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=73094"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/73094\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=73094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=73094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=73094"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=73094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}