11using Grand . Module . Api . Attributes ;
22using Microsoft . AspNetCore . Mvc ;
33using Microsoft . AspNetCore . OpenApi ;
4+ using Microsoft . OpenApi . Any ;
45using Microsoft . OpenApi . Models ;
56
67namespace Grand . Module . Api . Infrastructure . Extensions
@@ -45,7 +46,8 @@ public static void AddOperationTransformer(this OpenApiOptions options)
4546 Name = "$orderby" ,
4647 AllowReserved = true ,
4748 In = ParameterLocation . Query ,
48- Description = "Order items by property values" ,
49+ Description = "Order items by property values (LINQ notation)" ,
50+ Example = new OpenApiString ( "Name, DisplayOrder" ) ,
4951 Required = false ,
5052 Schema = new OpenApiSchema {
5153 Type = "string"
@@ -55,7 +57,8 @@ public static void AddOperationTransformer(this OpenApiOptions options)
5557 Name = "$filter" ,
5658 AllowReserved = true ,
5759 In = ParameterLocation . Query ,
58- Description = "Filter items by property values" ,
60+ Description = "Filter items by property values (LINQ notation) " ,
61+ Example = new OpenApiString ( "Name == \" John\" " ) ,
5962 Required = false ,
6063 Schema = new OpenApiSchema {
6164 Type = "string"
@@ -65,7 +68,8 @@ public static void AddOperationTransformer(this OpenApiOptions options)
6568 Name = "$select" ,
6669 AllowReserved = true ,
6770 In = ParameterLocation . Query ,
68- Description = "Select specific properties from the model" ,
71+ Description = "Select specific properties from the model (LINQ notation)" ,
72+ Example = new OpenApiString ( "Id, Name" ) ,
6973 Required = false ,
7074 Schema = new OpenApiSchema {
7175 Type = "string"
@@ -98,7 +102,7 @@ public static void AddCsrfTokenTransformer(this OpenApiOptions options)
98102 public static void AddContactDocumentTransformer ( this OpenApiOptions options , string name , string version )
99103 {
100104 options . AddDocumentTransformer ( ( document , context , cancellationToken ) =>
101- {
105+ {
102106 document . Info = new OpenApiInfo {
103107 Description = "Grandnode API" ,
104108 Title = name ,
@@ -117,5 +121,13 @@ public static void AddContactDocumentTransformer(this OpenApiOptions options, st
117121 return Task . CompletedTask ;
118122 } ) ;
119123 }
124+ public static void AddClearServerDocumentTransformer ( this OpenApiOptions options )
125+ {
126+ options . AddDocumentTransformer ( ( document , context , cancellationToken ) =>
127+ {
128+ document . Servers . Clear ( ) ;
129+ return Task . CompletedTask ;
130+ } ) ;
131+ }
120132 }
121133}
0 commit comments