Hi guys,
We've recently run through an exercise in updating the .Net Zero version of our project, as outlined here.
We've gone from 5.2.0 to 5.5.1 to 5.6.1. Swagger and API calls via Postman both worked previously when we were using 5.2.0 but now when trying to access Swagger we get an ERR_CONNECTION_REFUSED, and when we try and access an API method through Postman, for example, <a class="postlink" href="https://localhost:44359/api/TokenAuth/Authenticate">https://localhost:44359/api/TokenAuth/Authenticate</a>, Postman gives a "Could not get any response" message. We suspect that while these are two separate issues that they are in some way related?
Our application services are working via API within the application itself, just not through other methods as specified.
We also noticed that changes were made to Swagger during version 5.3.0, due to the adding of the Authorisation button? We're tried to add the changes, as detailed here, isn't working - these two issues are present:
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
app.UseSwaggerUI(options =>
{
//options.
options.InjectOnCompleteJavaScript("/swagger/ui/abp.js"); <- ERROR: SwaggerUi doesn't contain a definition for InjectOnCompleteJavaScript
options.InjectOnCompleteJavaScript("/swagger/ui/on-complete.js"); <- ERROR: SwaggerUi doesn't contain a definition for InjectOnCompleteJavaScript
options.SwaggerEndpoint(_appConfiguration["App:ServerRootAddress"] + "/swagger/v1/swagger.json", "Falcon API V1");
options.IndexStream = () => Assembly.GetExecutingAssembly()
.GetManifestResourceStream("Syntaq.Falcon.Web.Host.wwwroot.swagger.ui.index.html");
}); //URL: /swagger
And
// Define the BearerAuth scheme that's in use
options.AddSecurityDefinition("bearerAuth", new ApiKeyScheme()
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = "header",
Type = "apiKey"
});
// Assign scope requirements to operations based on AuthorizeAttribute
options.OperationFilter<SecurityRequirementsOperationFilter>(); <- ERROR: The type or namespace 'SecurityRequirementsOperationFilter' could not be found.
Has anyone else come across this issue and resolved it?
Thanks,
David
1 Answer(s)
-
0
options.InjectOnCompleteJavaScript("/swagger/ui/abp.js"); <- ERROR: SwaggerUi doesn't contain a definition for InjectOnCompleteJavaScript options.InjectOnCompleteJavaScript("/swagger/ui/on-complete.js"); <- ERROR: SwaggerUi doesn't contain a definition for InjectOnCompleteJavaScript
Those are implemented differently in ASP.NET Zero. Remove those.
options.OperationFilter<SecurityRequirementsOperationFilter>(); <- ERROR: The type or namespace 'SecurityRequirementsOperationFilter' could not be found.
That is not implemented in ASP.NET Zero. Grab that from SecurityRequirementsOperationFilter.cs.