0

I have written a JavaScript which I would like to inject in swagger with .Net Core 2.2. I would like to highlight that wwwroot folder wasn't created by default when I created web project (empty project option) with .Net Core 2.2. I then created wwwroot folder manually and added my JavaScript file inside that. When I am launching swagger, I am getting an error that file couldn't be loaded. I tried to create a folder "swagger" inside wwwroot and place a file there but that too didn't work. Here is my sample code:

SwaggerUIOptions uiConfig;
uiConfig.InjectJavascript("mycustomfile.js");

Also I would like to highlight what I am trying to achieve here. I got a drop-down in my header for a database provided i.e. Oracle/MSSQL etc. Now based on the selection, I want to change the value of another header i.e. connection string. I have written a JavaScript for this purpose but let me know if that can be achieved in some other and simplistic way as well with .Net Core along withSwashbuckle.

1
  • Can you access your "mycustomfile.js" from the browser? Jan 4, 2019 at 17:07

1 Answer 1

1

The issue got resolved after using app.UseStaticFiles(); in Configure() method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.