-
Notifications
You must be signed in to change notification settings - Fork 14
Tutorial 02 06 API Documentation
The Microsoft library that we use to implement API versioning can also automatically produce Swagger API documentation for the web service, and this behavior is now enabled by default in all Harmony Core services.
If you are working in a standard Harmony Core environment, the runtime-generated API documentation can be viewed here:
- In Visual Studio, press F5 (
Start Debugging
) to start the self-hosting application.
You should see the console window appear, with the messages confirming that your service is running.
-
Open a web browser and navigate to the API documentation URL:
You should see the API documentation home page, which at this point in the tutorial should look something like this:
If you scroll down this page, you'll see there are section headings for each of the main entity types. And below those headings are colored blocks that represent the endpoints that are available for the entity types.
Currently, you'll see only two operations for each entity. One is a GET operation (e.g., /Items) to retrieve the entire collection of entities. The other is a GET operation for $count
, which is not operational (because we haven't set the Enable collection count endpoints
option in the Harmony Core CLI tool).
- Click the blue
GET
button immediately belowCustomers
.
You should see the operation expand, and information about response types for the operation should be displayed (you may need to scroll down to this this):
The response information tells you which HTTP return codes could be generated by the endpoint, as well as the format of any data returned (JSON in this case). It also provides an example of what the return data will look like. In this case, the endpoint returns an array of objects, each of which has various properties (customerNumber, name, street, etc.).
Notice also a Try it Out
button near the top-right of the parameter information. This button puts the page into a mode where you can actually interact with the running web service.
- Click
Try it Out
, and then scroll down and click theExecute
button.
This causes the API documentation web app to issue an HTTP GET request to the endpoint and then display the response from the endpoint right in the documentation page, like this:
Under the Curl
label, you'll see the curl command you could use to make the same request from the command line. This is followed by the URL of the endpoint being accessed. And under that, you will see the actual response from the web service endpoint—HTTP 200 (OK) in this case—along with the data that was returned. Notice that at the lower right corner of the data window is a download button that enables you to download the raw data in a JSON file.
Below the data, you can also see the HTTP response headers that were returned with the data.
This is all very useful information for a programmer who intends to write code to interact with the web service. If the programmer understands the HTTP protocol, this documentation presents everything the programmer needs to know to access your service.
- When you are finished, stop the service by terminating the self-hosting program.
Next topic: Single Entity Endpoints
-
Tutorial 2: Building a Service from Scratch
- Creating a Basic Solution
- Enabling OData Support
- Configuring Self Hosting
- Entity Collection Endpoints
- API Documentation
- Single Entity Endpoints
- OData Query Support
- Alternate Key Endpoints
- Expanding Relations
- Postman Tests
- Supporting CRUD Operations
- Adding a Primary Key Factory
- Adding Create Endpoints
- Adding Upsert Endpoints
- Adding Patch Endpoints
- Adding Delete Endpoints
-
Harmony Core Code Generator
-
OData Aware Tools
-
Advanced Topics
- CLI Tool Customization
- Adapters
- API Versioning
- Authentication
- Authorization
- Collection Counts
- Customization File
- Custom Field Types
- Custom File Specs
- Custom Properties
- Customizing Generated Code
- Deploying to Linux
- Dynamic Call Protocol
- Environment Variables
- Field Security
- File I/O
- Improving AppSettings Processing
- Logging
- Optimistic Concurrency
- Multi-Tenancy
- Publishing in IIS
- Repeatable Unit Tests
- Stored Procedure Routing
- Suppressing OData Metadata
- Traditional Bridge
- Unit Testing
- EF Core Optimization
- Updating a Harmony Core Solution
- Updating to 3.1.90
- Creating a new Release
-
Background Information