{
- // reporting api versions will return the headers
- // "api-supported-versions" and "api-deprecated-versions"
- options.ReportApiVersions = true;
+ // reporting api versions will return the headers
+ // "api-supported-versions" and "api-deprecated-versions"
+ options.ReportApiVersions = true;
- // apply api versions using conventions rather than attributes
- options.Conventions.Controller
" );
+ description.Append( "**Links**" );
+ description.AppendLine( "
" );
+ rendered = true;
+ }
- if ( link.Type == "text/html" )
+ if ( StringSegment.IsNullOrEmpty( link.Title ) )
+ {
+ if ( link.LinkTarget.IsAbsoluteUri )
+ {
+ description.AppendLine( $"- {link.LinkTarget.OriginalString}" );
+ }
+ else
{
- if ( !rendered )
- {
- description.AppendLine();
- description.Append( "**Links**" );
- description.AppendLine();
- rendered = true;
- }
-
- if ( StringSegment.IsNullOrEmpty( link.Title ) )
- {
- if ( link.LinkTarget.IsAbsoluteUri )
- {
- description.AppendLine( $"- {link.LinkTarget.OriginalString}" );
- }
- else
- {
- description.AppendFormat( "- {0}", link.LinkTarget.OriginalString );
- description.AppendLine();
- }
- }
- else
- {
- description.AppendLine( $"- [{link.Title}]({link.LinkTarget.OriginalString})" );
- }
+ description.AppendFormat( "- {0}", link.LinkTarget.OriginalString );
+ description.AppendLine();
}
}
+ else
+ {
+ description.AppendLine( $"- [{link.Title}]({link.LinkTarget.OriginalString})" );
+ }
}
}
- description.AppendLine();
- description.AppendLine( "**Additional Information**" );
+ description.AppendLine().AppendLine( "
" );
+ description.AppendLine( "**Additional Information**
" );
info.Version( group.Name, $"Sample API {group.ApiVersion}" )
.Contact( c => c.Name( "Bill Mei" ).Email( "bill.mei@somewhere.com" ) )
.Description( description.ToString() )
diff --git a/examples/AspNet/OData/OpenApiODataWebApiExample/SwaggerDefaultValues.cs b/examples/AspNet/OData/OpenApiODataWebApiExample/SwaggerDefaultValues.cs
index 2ce56dcf..a26c8316 100644
--- a/examples/AspNet/OData/OpenApiODataWebApiExample/SwaggerDefaultValues.cs
+++ b/examples/AspNet/OData/OpenApiODataWebApiExample/SwaggerDefaultValues.cs
@@ -18,7 +18,7 @@ public class SwaggerDefaultValues : IOperationFilter
/// The API description being filtered.
public void Apply( Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription )
{
- operation.deprecated |= apiDescription.IsDeprecated();
+ operation.deprecated |= apiDescription.IsDeprecated;
if ( operation.parameters == null )
{
diff --git a/examples/AspNet/OData/OpenApiODataWebApiExample/V1/OrdersController.cs b/examples/AspNet/OData/OpenApiODataWebApiExample/V1/OrdersController.cs
index 8d42c15f..fe16d1ef 100644
--- a/examples/AspNet/OData/OpenApiODataWebApiExample/V1/OrdersController.cs
+++ b/examples/AspNet/OData/OpenApiODataWebApiExample/V1/OrdersController.cs
@@ -66,7 +66,7 @@ public IHttpActionResult Post( [FromBody] Order order )
[MapToApiVersion( "1.0" )]
[ResponseType( typeof( Order ) )]
[EnableQuery( AllowedQueryOptions = Select )]
- public SingleResult
" )
+ .AppendLine( "**Additional Information**" )
+ .AppendLine( "
" );
+
info.Version( group.Name, $"Sample API {group.ApiVersion}" )
.Contact( c => c.Name( "Bill Mei" ).Email( "bill.mei@somewhere.com" ) )
.Description( description.ToString() )
diff --git a/examples/AspNet/OData/SomeOpenApiODataWebApiExample/SwaggerDefaultValues.cs b/examples/AspNet/OData/SomeOpenApiODataWebApiExample/SwaggerDefaultValues.cs
index 2ce56dcf..a26c8316 100644
--- a/examples/AspNet/OData/SomeOpenApiODataWebApiExample/SwaggerDefaultValues.cs
+++ b/examples/AspNet/OData/SomeOpenApiODataWebApiExample/SwaggerDefaultValues.cs
@@ -18,7 +18,7 @@ public class SwaggerDefaultValues : IOperationFilter
/// The API description being filtered.
public void Apply( Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription )
{
- operation.deprecated |= apiDescription.IsDeprecated();
+ operation.deprecated |= apiDescription.IsDeprecated;
if ( operation.parameters == null )
{
diff --git a/examples/AspNet/WebApi/BasicWebApiExample/Controllers/Values2Controller.cs b/examples/AspNet/WebApi/BasicWebApiExample/Controllers/Values2Controller.cs
index ef7aa0ba..b390d4d8 100644
--- a/examples/AspNet/WebApi/BasicWebApiExample/Controllers/Values2Controller.cs
+++ b/examples/AspNet/WebApi/BasicWebApiExample/Controllers/Values2Controller.cs
@@ -13,6 +13,6 @@ public IHttpActionResult Get() =>
Ok( new
{
controller = GetType().Name,
- version = Request.GetRequestedApiVersion().ToString(),
+ version = Request.RequestedApiVersion.ToString(),
} );
}
\ No newline at end of file
diff --git a/examples/AspNet/WebApi/BasicWebApiExample/Controllers/ValuesController.cs b/examples/AspNet/WebApi/BasicWebApiExample/Controllers/ValuesController.cs
index 3d46c489..2ca558b8 100644
--- a/examples/AspNet/WebApi/BasicWebApiExample/Controllers/ValuesController.cs
+++ b/examples/AspNet/WebApi/BasicWebApiExample/Controllers/ValuesController.cs
@@ -10,8 +10,8 @@ public class ValuesController : ApiController
// GET api/values?api-version=1.0
public IHttpActionResult Get( ApiVersion apiVersion ) =>
Ok( new
- {
- controller = GetType().Name,
+ {
+ controller = GetType().Name,
version = apiVersion.ToString(),
} );
}
\ No newline at end of file
diff --git a/examples/AspNet/WebApi/BasicWebApiExample/Startup.cs b/examples/AspNet/WebApi/BasicWebApiExample/Startup.cs
index 05130216..547e46a6 100644
--- a/examples/AspNet/WebApi/BasicWebApiExample/Startup.cs
+++ b/examples/AspNet/WebApi/BasicWebApiExample/Startup.cs
@@ -12,7 +12,7 @@ public void Configuration( IAppBuilder builder )
// we only need to change the default constraint resolver for services
// that want urls with versioning like: ~/v{apiVersion}/{controller}
var constraintResolver = new DefaultInlineConstraintResolver()
- {
+ {
ConstraintMap = { ["apiVersion"] = typeof( ApiVersionRouteConstraint ) },
};
var configuration = new HttpConfiguration();
diff --git a/examples/AspNet/WebApi/ByNamespaceWebApiExample/Startup.cs b/examples/AspNet/WebApi/ByNamespaceWebApiExample/Startup.cs
index d5d67f53..6775b288 100644
--- a/examples/AspNet/WebApi/ByNamespaceWebApiExample/Startup.cs
+++ b/examples/AspNet/WebApi/ByNamespaceWebApiExample/Startup.cs
@@ -15,13 +15,13 @@ public void Configuration( IAppBuilder builder )
configuration.AddApiVersioning(
options =>
{
- // reporting api versions will return the headers
- // "api-supported-versions" and "api-deprecated-versions"
- options.ReportApiVersions = true;
+ // reporting api versions will return the headers
+ // "api-supported-versions" and "api-deprecated-versions"
+ options.ReportApiVersions = true;
- // automatically applies an api version based on the name of
- // the defining controller's namespace
- options.Conventions.Add( new VersionByNamespaceConvention() );
+ // automatically applies an api version based on the name of
+ // the defining controller's namespace
+ options.Conventions.Add( new VersionByNamespaceConvention() );
} );
// NOTE: you do NOT and should NOT use both the query string and url segment methods together.
diff --git a/examples/AspNet/WebApi/ConventionsWebApiExample/Controllers/Values2Controller.cs b/examples/AspNet/WebApi/ConventionsWebApiExample/Controllers/Values2Controller.cs
index 1d700c5c..f6fc6ad1 100644
--- a/examples/AspNet/WebApi/ConventionsWebApiExample/Controllers/Values2Controller.cs
+++ b/examples/AspNet/WebApi/ConventionsWebApiExample/Controllers/Values2Controller.cs
@@ -12,7 +12,7 @@ public IHttpActionResult Get() =>
Ok( new
{
controller = GetType().Name,
- version = Request.GetRequestedApiVersion().ToString(),
+ version = Request.RequestedApiVersion.ToString(),
} );
// GET api/values/{id}?api-version=2.0
@@ -22,7 +22,7 @@ public IHttpActionResult Get( int id ) =>
{
controller = GetType().Name,
id,
- version = Request.GetRequestedApiVersion().ToString(),
+ version = Request.RequestedApiVersion.ToString(),
} );
// GET api/values?api-version=3.0
@@ -31,7 +31,7 @@ public IHttpActionResult GetV3() =>
Ok( new
{
controller = GetType().Name,
- version = Request.GetRequestedApiVersion().ToString(),
+ version = Request.RequestedApiVersion.ToString(),
} );
// GET api/values/{id}?api-version=3.0
@@ -41,6 +41,6 @@ public IHttpActionResult GetV3( int id ) =>
{
controller = GetType().Name,
id,
- version = Request.GetRequestedApiVersion().ToString(),
+ version = Request.RequestedApiVersion.ToString(),
} );
}
\ No newline at end of file
diff --git a/examples/AspNet/WebApi/OpenApiWebApiExample/Startup.cs b/examples/AspNet/WebApi/OpenApiWebApiExample/Startup.cs
index 2a060f11..fb06af3a 100644
--- a/examples/AspNet/WebApi/OpenApiWebApiExample/Startup.cs
+++ b/examples/AspNet/WebApi/OpenApiWebApiExample/Startup.cs
@@ -37,10 +37,16 @@ public void Configuration( IAppBuilder builder )
// "api-supported-versions" and "api-deprecated-versions"
options.ReportApiVersions = true;
+ options.Policies.Deprecate( 0.9 )
+ .Effective( DateTimeOffset.Now )
+ .Link( "policy.html" )
+ .Title( "Version Deprecation Policy" )
+ .Type( "text/html" );
+
options.Policies.Sunset( 0.9 )
.Effective( DateTimeOffset.Now.AddDays( 60 ) )
.Link( "policy.html" )
- .Title( "Versioning Policy" )
+ .Title( "Version Sunset Policy" )
.Type( "text/html" );
} );
configuration.MapHttpAttributeRoutes( constraintResolver );
@@ -64,70 +70,98 @@ public void Configuration( IAppBuilder builder )
{
// build a swagger document and endpoint for each discovered API version
swagger.MultipleApiVersions(
- ( apiDescription, version ) => apiDescription.GetGroupName() == version,
+ ( apiDescription, version ) => apiDescription.GroupName == version,
info =>
{
foreach ( var group in apiExplorer.ApiDescriptions )
{
var description = new StringBuilder( "A sample application with OpenAPI, Swashbuckle, and API versioning." );
+ var links = new List
" );
+ description.Append( "**Links**" );
+ description.AppendLine( "
" );
+ rendered = true;
+ }
- if ( link.Type == "text/html" )
+ if ( StringSegment.IsNullOrEmpty( link.Title ) )
+ {
+ if ( link.LinkTarget.IsAbsoluteUri )
+ {
+ description.AppendLine( $"- {link.LinkTarget.OriginalString}" );
+ }
+ else
{
- if ( !rendered )
- {
- description.AppendLine();
- description.Append( "**Links**" );
- description.AppendLine();
- rendered = true;
- }
-
- if ( StringSegment.IsNullOrEmpty( link.Title ) )
- {
- if ( link.LinkTarget.IsAbsoluteUri )
- {
- description.AppendLine( $"- {link.LinkTarget.OriginalString}" );
- }
- else
- {
- description.AppendFormat( "- {0}", link.LinkTarget.OriginalString );
- description.AppendLine();
- }
- }
- else
- {
- description.AppendLine( $"- [{link.Title}]({link.LinkTarget.OriginalString})" );
- }
+ description.AppendFormat( "- {0}", link.LinkTarget.OriginalString );
+ description.AppendLine();
}
}
+ else
+ {
+ description.AppendLine( $"- [{link.Title}]({link.LinkTarget.OriginalString})" );
+ }
}
}
- description.AppendLine();
- description.AppendLine( "**Additional Information**" );
+ description.AppendLine().AppendLine( "
" );
+ description.AppendLine( "**Additional Information**
" );
info.Version( group.Name, $"Example API {group.ApiVersion}" )
.Contact( c => c.Name( "Bill Mei" ).Email( "bill.mei@somewhere.com" ) )
.Description( description.ToString() )
diff --git a/examples/AspNet/WebApi/OpenApiWebApiExample/SwaggerDefaultValues.cs b/examples/AspNet/WebApi/OpenApiWebApiExample/SwaggerDefaultValues.cs
index dc26ff66..3819f01b 100644
--- a/examples/AspNet/WebApi/OpenApiWebApiExample/SwaggerDefaultValues.cs
+++ b/examples/AspNet/WebApi/OpenApiWebApiExample/SwaggerDefaultValues.cs
@@ -18,7 +18,7 @@ public class SwaggerDefaultValues : IOperationFilter
/// The API description being filtered.
public void Apply( Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription )
{
- operation.deprecated |= apiDescription.IsDeprecated();
+ operation.deprecated |= apiDescription.IsDeprecated;
if ( operation.parameters == null )
{
diff --git a/examples/AspNetCore/OData/Directory.Build.props b/examples/AspNetCore/OData/Directory.Build.props
index 0c6cf639..d75382b4 100644
--- a/examples/AspNetCore/OData/Directory.Build.props
+++ b/examples/AspNetCore/OData/Directory.Build.props
@@ -4,7 +4,7 @@