Skip to content

Commit

Permalink
Supports route prefixes that contain parameters. Closes #57.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Beauchamp committed Feb 8, 2016
1 parent e933dc0 commit c498a75
Show file tree
Hide file tree
Showing 13 changed files with 625 additions and 68 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,32 @@ config.AddCustomSwaggerRoute(restierRoute, "/Customers({CustomerId})/Orders({Ord
.PathParameter<int>("OrderId");
```

### Route prefixes that have parameters ###

The follow snippet demonstrates how to configure route prefixes that have parameters:

```csharp
// For example, if you have a route prefix with a parameter "tenantId" of type long
var odataRoute = config.MapODataServiceRoute("odata", "odata/{tenantId}", builder.GetEdmModel());

// Then add the following route constraint so that Swashbuckle.OData knows the parameter type.
// If you don't add this line then the parameter will be assumed to be of type string.
odataRoute.Constraints.Add("tenantId", new LongRouteConstraint());
```
Swashbuckle.OData supports the following route constraints:

| Parameter Type | Route Constraint |
|----------------|---------------------------|
| `bool` | `BoolRouteConstraint` |
| `DateTime` | `DateTimeRouteConstraint` |
| `decimal` | `DecimalRouteConstraint` |
| `double` | `DoubleRouteConstraint` |
| `float` | `FloatRouteConstraint` |
| `Guid` | `GuidRouteConstraint` |
| `int` | `IntRouteConstraint` |
| `long` | `LongRouteConstraint` |


### OWIN ###

If your service is hosted using OWIN middleware, configure the custom provider as follows:
Expand Down
4 changes: 2 additions & 2 deletions Swashbuckle.OData.Nuget/Swashbuckle.OData.NuGet.nuproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<Owners>Richard Beauchamp</Owners>
<Summary>Extends Swashbuckle with OData v4 support!</Summary>
<Description>Extends Swashbuckle with OData v4 support!</Description>
<ReleaseNotes>Supports decimal parameters, keys and return types.</ReleaseNotes>
<ReleaseNotes>Supports route prefixes that contain parameters.</ReleaseNotes>
<ProjectUrl>https://github.com/rbeauchamp/Swashbuckle.OData</ProjectUrl>
<LicenseUrl>https://github.com/rbeauchamp/Swashbuckle.OData/blob/master/License.txt</LicenseUrl>
<Copyright>Copyright 2015</Copyright>
<Tags>Swashbuckle Swagger SwaggerUi OData Documentation Discovery Help WebApi AspNet AspNetWebApi Docs WebHost IIS</Tags>
<Version>2.13.0</Version>
<Version>2.14.0</Version>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Swashbuckle.OData\Swashbuckle.OData.csproj" />
Expand Down
Loading

0 comments on commit c498a75

Please sign in to comment.