1. Alex Riofrio
  2. PowerServer
  3. Monday, 29 November 2021 20:03 PM UTC

Hi everyone;
Please, Does anyone have information about how to configure "Swagger" (that comes integrated with PowerServer 2021) so that it can work over HTTPS?

Any info is welcome.
Thanks.

Alex

 

Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Monday, 29 November 2021 20:17 PM UTC
  2. PowerServer
  3. # 1

Hi Alex,

If you're working with Kestrel you can modify the launchSettings.json file and in the applicationUrl add another URL for the secure connection. For example, I changed it from

 

{
  "profiles": {
    "ServerAPIs": {
      "launchBrowser": true,
      "applicationUrl": "http://0.0.0.0:5000",
      "commandName": "Project",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "launchUrl": "swagger",
      "ischecked": "true"
    }
  }
}

 

to

{
  "profiles": {
    "ServerAPIs": {
      "launchBrowser": true,
      "applicationUrl": "http://0.0.0.0:5000/;https://0.0.0.0:5001",
      "commandName": "Project",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "launchUrl": "swagger",
      "ischecked": "true"
    }
  }
}

 

and that serves the Swagger application on HTTPS on port 5001


If you're using SnapDevelop you can open the ServerAPIs project's properties to change this setting:

 

If you're using something other than Kestrel, you have to check the respective documentation for the Web Server you're using to serve the WebAPIs

 

Regards,
Francisco

Comment
  1. Alex Riofrio
  2. Monday, 29 November 2021 20:36 PM UTC
Thanks Francisco for your kind answer.

In this case PS 2021 is working on IIS with HTTPS. The Web API works fine but swagger doesn't.



Alex.
  1. Helpful
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 30 November 2021 19:50 PM UTC
  2. PowerServer
  3. # 2

Hi Alex,

Swagger, by default, is only enabled on the Development build profile for the Web APIs. You can change this behavior by modifying the Server APIs' Startup.cs as follows:

 

Move the app.UsePowerServerOpenAPI(); file to after the closing curly bracket:

After this is done, you will need to redeploy the application and restart IIS.

With this you will have exposed Swagger on production.

Hope this helps.

Regards,
Francisco

Comment
  1. Alex Riofrio
  2. Friday, 3 December 2021 23:08 PM UTC
Thank you very much Francisco.

Very helpful tip! :)
  1. Helpful
There are no comments made yet.
Javier Garcia Martin Accepted Answer Pending Moderation
  1. Monday, 4 March 2024 12:28 PM UTC
  2. PowerServer
  3. # 3

When I run my project in development, Swagger is deployed locally at: https://localhost:5001/swagger/index.html

How can I publish my Swagger project on the application server so that my clients can access it and view my API documentation? Currently, I take the generated JSON file, export it to Swagger, and publish the service, but I lose many of the properties that I have configured during development. I would like to know if after running in the development environment (Swagger), I can create an identical service in production.

Thanks.

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.