Hi,
we have updated to .net core and also latest servicestack.
Now when we check in swagger it’s missing the Skip, Take query parameters.
When did Swagger UI show base class properties, What version did you upgrade from?
Hi,
it was showing when we ran
<PackageReference Include="ServiceStack.Api.Swagger" Version="5.7.0" />
<PackageReference Include="ServiceStack.MsgPack" Version="5.7.0" />
<PackageReference Include="ServiceStack.OrmLite.SqlServer" Version="5.7.0" />
Now we are running
<PackageReference Include="ServiceStack" Version="6.11.1" />
<PackageReference Include="ServiceStack.Api.OpenApi" Version="6.*" />
<PackageReference Include="ServiceStack.Redis.Core" Version="6.11.0" />
How are you adding the customization, e.g. description and examples for these fields?
Im not sure if this is what you ask about but here is the setup
Plugins.Add(new AutoQueryFeature { MaxLimit = 1000 });
Plugins.Add(new SharpPagesFeature
{
MetadataDebugAdminRole = RoleNames.AllowAnon, // Allow Authenticated Users
});
Plugins.Add(new OpenApiFeature()
{
DisableSwaggerUI = false,
ApiDeclarationFilter = api =>
{
if (!api.SecurityDefinitions.ContainsKey("apiKey"))
{
api.SecurityDefinitions.Add(
"apiKey", new OpenApiSecuritySchema
{
Type = "apiKey",
Name = "x-api-key", // Use "x-api-key" as the header name
In = "header",
Description = "API Key Authentication"
});
}
},
OperationFilter = (verb, op) =>
{
if (op.RequestType == nameof(UploadImagesRequest) && verb == HttpMethods.Post)
{
op.Parameters.Add(new OpenApiParameter
{
Name = "upload",
In = "body",
Description = "Upload image", // Optional description
Required = true, // Set to true if the parameter is required
Schema = new OpenApiSchema
{
Type = "string",
Format = "binary" // Use "binary" for file uploads
}
});
}
}
});
Your fields like Skip
has descriptions and examples I’ve not seen before, e.g:
Skip over a given number of elements in a sequence and then return the remainder.
Use this when you need paging.
Example:
?skip=10&orderBy=Id
Do you know where it’s coming from?
Yes we have a SwaggerMetada.cs file with this
typeof (QueryBase) .GetProperty("Skip") .AddAttributes(new ApiMemberAttribute { Description = "Skip over a given number of elements in a sequence and then return the remainder. Use this when you need paging.<br/><br/><strong>Example:</strong><br/><code>?skip=10&orderBy=Id</code>", DataType = "int", ParameterType = "query" }); typeof (QueryBase) .GetProperty("Take") .AddAttributes(new ApiMemberAttribute { Description = "Return a given number of elements in a sequence and then skip over the remainder. Use this when you need paging.<br/><br/><strong>Example:</strong><br/><code>?take=20</code>", DataType = "int", ParameterType = "query" }); typeof (QueryBase) .GetProperty("OrderBy") .AddAttributes(new ApiMemberAttribute { Description = "Comma separated list of fields to order by. Prefix the field name with a minus if you wan't to invert the sort for that field.<br/><br/><strong>Example:</strong><br/><code>?orderBy=Id,-Age,FirstName</code>", DataType = "string", ParameterType = "query" });
I think i found the problem, we had removed this class when upgrading. Sorry for this