Skip to content

Commit 2edb359

Browse files
committed
apply changes from dotnet#34676
1 parent f225fc8 commit 2edb359

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

aspnetcore/tutorials/first-web-api.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
title: "Tutorial: Create a web API with ASP.NET Core"
2+
title: "Tutorial: Create a controller-based web API with ASP.NET Core"
33
author: wadepickett
4-
description: Learn how to build a web API with ASP.NET Core.
4+
description: Learn how to build a controller-based web API with ASP.NET Core.
55
ms.author: wpickett
66
ms.custom: mvc, engagement-fy24
77
ms.date: 02/17/2025
88
uid: tutorials/first-web-api
99
---
1010

11-
# Tutorial: Create a web API with ASP.NET Core
11+
# Tutorial: Create a controller-based web API with ASP.NET Core
1212

1313
[!INCLUDE[](~/includes/not-latest-version.md)]
1414

@@ -46,7 +46,7 @@ The following diagram shows the design of the app.
4646

4747
---
4848

49-
## Create a web project
49+
## Create a Web API project
5050

5151
# [Visual Studio](#tab/visual-studio)
5252

@@ -109,7 +109,11 @@ Visual Studio launches a terminal window and prints out the URL of the running a
109109
```output
110110
...
111111
info: Microsoft.Hosting.Lifetime[14]
112-
Now listening on: https://localhost:{port}
112+
Now listening on: https://localhost:7260
113+
info: Microsoft.Hosting.Lifetime[14]
114+
Now listening on: http://localhost:7261
115+
info: Microsoft.Hosting.Lifetime[0]
116+
Application started. Press Ctrl+C to shut down.
113117
...
114118
```
115119

@@ -121,31 +125,31 @@ The browser displays JSON similar to the following example:
121125
```json
122126
[
123127
{
124-
"date": "2025-07-16T19:04:05.7257911-06:00",
128+
"date": "2025-07-16",
125129
"temperatureC": 52,
126130
"temperatureF": 125,
127131
"summary": "Mild"
128132
},
129133
{
130-
"date": "2025-07-17T19:04:05.7258461-06:00",
134+
"date": "2025-07-17",
131135
"temperatureC": 36,
132136
"temperatureF": 96,
133137
"summary": "Warm"
134138
},
135139
{
136-
"date": "2025-07-18T19:04:05.7258467-06:00",
140+
"date": "2025-07-18",
137141
"temperatureC": 39,
138142
"temperatureF": 102,
139143
"summary": "Cool"
140144
},
141145
{
142-
"date": "2025-07-19T19:04:05.7258471-06:00",
146+
"date": "2025-07-19",
143147
"temperatureC": 10,
144148
"temperatureF": 49,
145149
"summary": "Bracing"
146150
},
147151
{
148-
"date": "2025-07-20T19:04:05.7258474-06:00",
152+
"date": "2025-07-20",
149153
"temperatureC": -1,
150154
"temperatureF": 31,
151155
"summary": "Chilly"
@@ -183,31 +187,31 @@ Run the app:
183187
```json
184188
[
185189
{
186-
"date": "2025-07-16T19:04:05.7257911-06:00",
190+
"date": "2025-07-16",
187191
"temperatureC": 52,
188192
"temperatureF": 125,
189193
"summary": "Mild"
190194
},
191195
{
192-
"date": "2025-07-17T19:04:05.7258461-06:00",
196+
"date": "2025-07-17",
193197
"temperatureC": 36,
194198
"temperatureF": 96,
195199
"summary": "Warm"
196200
},
197201
{
198-
"date": "2025-07-18T19:04:05.7258467-06:00",
202+
"date": "2025-07-18",
199203
"temperatureC": 39,
200204
"temperatureF": 102,
201205
"summary": "Cool"
202206
},
203207
{
204-
"date": "2025-07-19T19:04:05.7258471-06:00",
208+
"date": "2025-07-19",
205209
"temperatureC": 10,
206210
"temperatureF": 49,
207211
"summary": "Bracing"
208212
},
209213
{
210-
"date": "2025-07-20T19:04:05.7258474-06:00",
214+
"date": "2025-07-20",
211215
"temperatureC": -1,
212216
"temperatureF": 31,
213217
"summary": "Chilly"
@@ -256,8 +260,12 @@ Because our project is using OpenAPI, we only use the NSwag package to generate
256260

257261
:::code language="csharp" source="~/tutorials/first-web-api/samples/9.0/TodoApi_SwaggerVersion/Program.cs" id="snippet_UseSwagger":::
258262

259-
The previous code enables the Swagger middleware for serving the generated JSON document and the Swagger UI. Swagger is only enabled in a development environment. Enabling Swagger in a production environment could expose potentially sensitive details about the API's structure and implementation.
260-
To generate the UI, it uses the OpenAPI document generated by OpenApi, located at `/openapi/v1.json`.
263+
The previous code enables the Swagger middleware for serving the generated JSON document using the Swagger UI. Swagger is only enabled in a development environment. Enabling Swagger in a production environment could expose potentially sensitive details about the API's structure and implementation.
264+
265+
To generate the UI, it uses the OpenAPI document generated by OpenApi, located at `/openapi/v1.json`.
266+
View the generated OpenAPI specification for the `WeatherForecast` API while the project is running by navigating your browser to `https://localhost:<port>/openapi/v1.json`.
267+
268+
The OpenAPI specification is a document in JSON format that describes the structure and capabilities of your API, including endpoints, request/response formats, parameters, and more. It's essentially a blueprint of your API that can be used by various tools to understand and interact with your API.
261269

262270
---
263271

@@ -458,8 +466,8 @@ The <xref:Microsoft.AspNetCore.Mvc.ControllerBase.CreatedAtAction%2A> method:
458466
Content-Type: application/json
459467
460468
{
461-
"name":"walk dog",
462-
"isComplete":true
469+
"name": "walk dog",
470+
"isComplete": true
463471
}
464472
465473
###
@@ -824,6 +832,7 @@ For more information, see the following resources:
824832

825833
* <xref:web-api/index>
826834
* <xref:tutorials/min-web-api>
835+
* <xref:fundamentals/openapi/using-openapi-documents>
827836
* <xref:tutorials/web-api-help-pages-using-swagger>
828837
* <xref:data/ef-rp/intro>
829838
* <xref:mvc/controllers/routing>

0 commit comments

Comments
 (0)