Skip to content

Web API

This is an ‘Endpoint’ type component that exposes data using ASP.NET Web API.

When using this component, the code generator creates two projects. The first is WebApi project, and the second project contains all the models (simplified entity classes) exposed by WebApi.

Configuration

solutionName: "Axellon.Entity.Demo"
dataApi:
    entityGroups:
      - group: default

        readComponents:
          - type: MongoDbComponent

        writeComponents:
          - type: ValidationComponent

          - type: MongoDbComponent
        endpoints:
          - type: WebApiEndpoint

API Docs

The generated Web API project is configured to serve the Swagger UI for browsing and testing the Web API and the Redoc for read-only documentation.

Swagger UI can be found on the /interactive-docs and Redoc at /docs route.

If you are running the app locally, the URL-s will be something like :

Swagger UI : https://localhost:64526/interactive-docs

1715445336440

Redoc: https://localhost:64526/docs

1715443618898

Versioning

The API versioning is implemented by exposing the version number in the URI.

For example, this is the 1.1 version of the Assets endpoint:

https://localhost:64526/v1.1/assets

It is configured in the Startup.cs file in the Web project and can be customized. The version can be specified using the ApiVersion attribute on the controller.

Http files

Entity Services generates .http files for every entity and provides a straightforward and quick way to test the generated endpoints.

Although they can be run on most modern IDEs, the recommended way is to run them in Visual Studio Code with the Rest Client extension, which can be installed from this link: REST Client - Visual Studio Marketplace.

The generated scripts make full use of REST Client’s advanced features like passing the results from one HTTP method as a parameters to the next methods.

Back to top