-
Notifications
You must be signed in to change notification settings - Fork 25.1k
API v endpoint v operation /1 #35325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
42ccbd0
API v endpoint v operation
Rick-Anderson 8cc19ed
API v endpoint v operation
Rick-Anderson 4251699
API v endpoint v operation
Rick-Anderson 9bfdb45
Apply suggestions from code review
Rick-Anderson 82915c3
react to feedback
Rick-Anderson c33acbb
react to feedback
Rick-Anderson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
aspnetcore/fundamentals/openapi/includes/api_endpoint_operation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| ## API v. API operation v. API endpoint | ||
|
|
||
| The following sections explain the differences between an API, an API endpoint, and an API operation in the context of ASP.NET Core and OpenAPI documentation. | ||
|
|
||
| ### API (Application Programming Interface) | ||
|
|
||
| An API is a set of rules and protocols for building and interacting with software applications. It defines how different software components should communicate. An API typically refers to a web service that exposes functionality over HTTP. | ||
|
|
||
| In ASP.NET Core, an API is usually built using controllers or minimal APIs, which handle incoming HTTP requests and return responses. | ||
|
|
||
| ### API Operation | ||
|
|
||
| An API operation represents a specific action or capability that an API provides. In ASP.NET Core, this corresponds to: | ||
|
|
||
| * Controller action methods in MVC-style APIs | ||
| * Route handlers in Minimal APIs | ||
|
|
||
| Each operation is defined by its HTTP method (`GET`, `POST`, `PUT`, etc.), parameters, and responses. | ||
Rick-Anderson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### API Endpoint | ||
|
|
||
| An API endpoint is a specific URL: | ||
|
|
||
| * That represents a specific resource or functionality exposed by the API. | ||
| * Provides the exact address that a client needs to send an HTTP request to in order to interact with a particular API operation. | ||
|
|
||
| An endpoint is a combination of the API's base URL and a specific path to the desired resource, along with the supported HTTP methods: | ||
|
|
||
| * For controller-based APIs, endpoints combine the route template with controller and action. | ||
| * For Minimal APIs, endpoints are explicitly defined with `app.MapGet()`, `app.MapPost()`, etc. | ||
|
|
||
| For example: | ||
|
|
||
| * `GET /api/products` | ||
| * `POST /api/products` | ||
| * `PUT /api/products/{id}` | ||
|
|
||
mikekistler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### OpenAPI Documentation | ||
|
|
||
| In the context of OpenAPI, the documentation describes the API as a whole, including all its endpoints and operations. OpenAPI provides a structured way to document APIs, making it easier for developers to understand how to interact with them. | ||
|
|
||
| API Operations are the primary focus of OpenAPI documentation. The [OpenAPI specification](https://spec.openapis.org/oas/latest.html) organizes documentation by operations, which are grouped by paths (endpoints). Each operation is described with details such as parameters, request bodies, responses, and more. This structured format allows tools to generate client libraries, server stubs, and interactive documentation automatically. | ||
|
|
||
| In a OpenAPI document: | ||
Rick-Anderson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| * The entire document describes the API as a whole | ||
| * Each path item (like `/api/products/{id}`) represents an endpoint | ||
| * Under each path, the HTTP methods (`GET`, `POST`, `PUT`, etc.) define the operations | ||
| * Each operation contains details about parameters, request body, responses, etc. | ||
|
|
||
| Example in OpenAPI JSON format: | ||
|
|
||
| ```JSON | ||
| json{ | ||
| "paths": { | ||
| "/api/products/{id}": { // This is the endpoint | ||
| "get": { // This is the operation | ||
| "summary": "Get a product by ID", | ||
| "parameters": [...], | ||
| "responses": {...} | ||
| }, | ||
| "put": { // Another operation on the same endpoint | ||
| "summary": "Update a product", | ||
| "parameters": [...], | ||
| "responses": {...} | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## API v. API operation v. API endpoint | ||
|
|
||
| | Concept | API Operation | API Endpoint | | ||
| |-----------------|----------------------------------------------------|--------------------------------------------------| | ||
| | **Definition** | A logical description of an API action: method + path + behavior | The actual configured HTTP route that listens for requests | | ||
| | **Level** | Conceptual, what action can happen | Concrete, what URL and method are matched | | ||
| | **Tied to** | OpenAPI API design/specification | ASP.NET Core routing at runtime | | ||
| | **Describes** | What the API does for example, "create product" | Where and how to call it, for example, `POST https://localhost:7099/api/products`, `POST https://contoso.com/api/products` | | ||
| | **In ASP.NET Core** | Controller actions or Minimal API methods, before routing resolves | Endpoint objects resolved at runtime | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.