Cohesive.Api
0.1.0-alpha.158
dotnet add package Cohesive.Api --version 0.1.0-alpha.158
NuGet\Install-Package Cohesive.Api -Version 0.1.0-alpha.158
<PackageReference Include="Cohesive.Api" Version="0.1.0-alpha.158" />
<PackageVersion Include="Cohesive.Api" Version="0.1.0-alpha.158" />
<PackageReference Include="Cohesive.Api" />
paket add Cohesive.Api --version 0.1.0-alpha.158
#r "nuget: Cohesive.Api, 0.1.0-alpha.158"
#:package Cohesive.Api@0.1.0-alpha.158
#addin nuget:?package=Cohesive.Api&version=0.1.0-alpha.158&prerelease
#tool nuget:?package=Cohesive.Api&version=0.1.0-alpha.158&prerelease
Cohesive.Api
Instance composition
ApiModel optionally groups typed endpoint properties on an instance. Author with the protected Endpoints builder; inherited Definition freezes and caches the contract. Existing ApiDefinition.Combine composes independent contract contributions and rejects duplicate endpoint IDs. Runtime implementation composition remains separate.
Semantic API declaration primitives for describing operations, endpoints, pagination, scope policies, and generated API artifacts.
This package is host-neutral. HTTP bindings describe portable API intent; they do not reference ASP.NET Core or map runtime routes. Concrete host projection belongs to an adapter.
Install
dotnet add package Cohesive.Api
Use When
- You want an API surface to be declared as semantic operations before projecting it to HTTP, OpenAPI, GraphQL, or TypeScript clients.
- You need shared endpoint metadata that can be interpreted by multiple adapters.
- You want API declarations to stay close to Cohesive shapes, presentation modules, relations, or process definitions.
Example
using Cohesive.Api;
var dispatch = compiledDispatchPlan.DefinitionReference;
var api = Api.Define("Shipping")
.Entity<Shipment>()
.Query("GetById")
.Route("GET", "/api/shipments/{id}")
.Returns<ShipmentDto>()
.Done()
.Command("Dispatch")
.Route("POST", "/api/shipments/{id}/dispatch")
.Accepts<DispatchShipmentRequest>()
.Transition(dispatch)
.Done()
.Build();
Optional execution control
The canonical Process execution-control catalog intentionally lives in Cohesive.Api.Execution. That optional
composition package binds these generic declarations to Cohesive.Processes contracts without making every
Cohesive.Api consumer acquire the Process language and runtime.
ASP.NET projection
ASP.NET endpoint mapping lives in Cohesive.Adapters.AspNet. Hosts add that package and import its namespace:
using Cohesive.Adapters.AspNet;
app.MapApiDefinition(api, operation => CreateHandler(operation));
MapApiDefinition, MapApiEndpoint, and AspNetAuthorizationPolicyResolver previously lived in the
Cohesive.Api assembly and namespace. They moved without a forwarding shim so this package can remain independent
of Microsoft.AspNetCore.App.
Related Packages
- Execution Kernel adoption and migration guide for the common status, trace, explain, and telemetry projection contract.
Cohesive.Api.Executionfor the canonical route-neutral Process execution-control catalog and reference integration.Cohesive.Adapters.AspNetfor ASP.NET endpoint projection.Cohesive.Adapters.OpenApifor OpenAPI emission.Cohesive.Adapters.GraphQLfor GraphQL schema emission.Cohesive.Adapters.TypeScriptfor TypeScript client generation.
Service declarations
Services.ServiceDefinition groups exact Transition, query, Process-entry and Process-control operations
into a portable authority using the existing execution-definition document, provenance and fingerprints.
Referenced definitions own input/output and behavior. Control actions use the native Process-control
vocabulary; requirements are declared per exposed operation. Native repositories, dispatchers and HTTP
routes are runtime/projection bindings, never stored callbacks. The optional Cohesive.Api.Execution
package provides shared invocation and normalized authorization.
See declarative service runtime.
Response-typed endpoint handles
declaration.Result(ApiResultKind.NotFound).Build<OrderDetails>() produces an
ApiEndpoint<OrderDetails>. The tag describes the primary body; 404 and other alternatives keep their
own contracts. The handle shares the exact ApiOperation registered in the definition, and WithHttp
retains the tag. A mismatched tag fails before registering an operation. Typed query bindings accept
ApiEndpoint<TResult> alongside IRelationQueryReader<TInput,TResult>, so unrelated response types
cannot be paired by type inference. Untyped handles remain available for heterogeneous API catalogs.
Build<OrderCreated>(ApiResultKind.Created) declares a typed 201 response in one call. Omitting the kind
defaults to Success, or retains an existing declaration. Explicit Returns declarations remain supported;
typed Build validates them instead of silently replacing their type or result kind.
Request-and-response handles
Use an explicit transport completion to declare both types once:
ApiEndpoint<CreateOrder, OrderCreated> create = api.Command("Create")
.Route("POST", "/orders")
.BuildBody<CreateOrder, OrderCreated>(ApiResultKind.Created);
ApiEndpoint<FindOrders, OrderList> find = api.Query("Find")
.Route("GET", "/orders")
.BuildQuery<FindOrders, OrderList>();
The request tag describes the API body/query DTO, not an internal transition input or route scalar.
Route-only operations retain ApiEndpoint<TResponse>. For an already declared Body<TRequest>(),
Query<TRequest>() or Accepts<TRequest>(), Build<TRequest,TResponse>() validates and retains that
request contract. Conflicting types/transports fail before operation registration; repeated completion
retains the same canonical operation. WithHttp retains both tags and rejects incompatible DTO bindings.
Untyped endpoint catalogs and native delegate mapping remain available; the tags alone do not validate
an arbitrary ASP.NET Delegate handler's signature or select request parsing implicitly.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Cohesive (>= 0.1.0-alpha.158)
- Cohesive.Relations (>= 0.1.0-alpha.158)
- Cohesive.Transitions (>= 0.1.0-alpha.158)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on Cohesive.Api:
| Package | Downloads |
|---|---|
|
Cohesive.Api.Execution
Canonical execution-control API declarations and reference integration for Cohesive execution semantics. |
|
|
Cohesive.Adapters.GraphQL
Cohesive semantic system definition and orchestration building blocks. |
|
|
Cohesive.Adapters.TypeScript
Cohesive semantic system definition and orchestration building blocks. |
|
|
Cohesive.Adapters.OpenApi
Cohesive semantic system definition and orchestration building blocks. |
|
|
Cohesive.CodeGen.Cli
Cohesive semantic system definition and orchestration building blocks. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-alpha.158 | 136 | 10/24/2026 |
| 0.1.0-alpha.157 | 132 | 10/24/2026 |
| 0.1.0-alpha.156 | 126 | 10/22/2026 |
| 0.1.0-alpha.155 | 130 | 10/20/2026 |
| 0.1.0-alpha.154 | 131 | 10/20/2026 |
| 0.1.0-alpha.153 | 131 | 10/20/2026 |
| 0.1.0-alpha.152 | 118 | 10/19/2026 |
| 0.1.0-alpha.151 | 121 | 10/19/2026 |
| 0.1.0-alpha.150 | 128 | 10/19/2026 |
| 0.1.0-alpha.149 | 129 | 10/18/2026 |
| 0.1.0-alpha.148 | 145 | 10/18/2026 |
| 0.1.0-alpha.147 | 132 | 10/18/2026 |
| 0.1.0-alpha.146 | 125 | 10/18/2026 |
| 0.1.0-alpha.145 | 120 | 10/17/2026 |
| 0.1.0-alpha.144 | 127 | 10/17/2026 |
| 0.1.0-alpha.143 | 134 | 10/16/2026 |
| 0.1.0-alpha.142 | 122 | 10/16/2026 |
| 0.1.0-alpha.141 | 133 | 10/16/2026 |
| 0.1.0-alpha.140 | 137 | 10/15/2026 |
| 0.1.0-alpha.139 | 147 | 10/13/2026 |