Pode icon indicating copy to clipboard operation
Pode copied to clipboard

Enable-PodeOpenApi should allow for alias in iis

Open Omzig opened this issue 3 years ago • 4 comments

Describe the Change

As a developer, I want Enable-PodeOpenApi to support swagger servers so that i can use an IIS alias application folder like https://pode.domain.com/myService.

I don't know what you want to call it, but maybe something like this:

  • Enable-PodeOpenApi -Title 'Data Warehouse' -Version 0.0.0.1 -RouteFilter '/api/*' -alias '/myService'
  • or
  • Enable-PodeOpenApi -Title 'Data Warehouse' -Version 0.0.0.1 -RouteFilter '/api/*' -servers '/myService'

image

Related Issues

When using the 'Try it out' button, swagger will does not know there is a server alias.

Additional Context

Example of a good open api configuration file:

{
  "openapi": "3.0.1",
  "info": {
    "title": "Data Warehouse",
    "version": "v1"
  },
  "servers": [
    {
      "url": "/myService"
    }
  ],
  "paths": {
    "/api/test-kerberos": {

This would then build the url with the alias in the request url when using swaggers try it out button.

No alias

Example of Pode's open api file:

	"openapi": "3.0.2",
	"info": {
		"title": "Self Service Catalog API",
		"version": "0.0.0.1"
	},
        "paths": {
		"/api/test-kerberos": {

Omzig avatar Aug 04 '22 19:08 Omzig

Hi @Omzig,

Are you referring to running Pode as an Application under another IIS Website? If so, Pode actually supports this already, and uses the path during route matching. It just needs appending on the OpenAPI URLs 😃

Badgerati avatar Aug 04 '22 22:08 Badgerati

Hi @Omzig,

Are you referring to running Pode as an Application under another IIS Website? If so, Pode actually supports this already, and uses the path during route matching. It just needs appending on the OpenAPI URLs 😃

Yes the application in IIS is called /myService, it causes the url to look like this https://pode.domain.com/myService/api/swagger Can you tell me what documentation i missed to include the the proper routing in swagger?

Start-PodeServer -StatusPageExceptions Show -Threads 10 {
  Add-PodeEndpoint -Address localhost -Protocol Http
  Add-PodeAuthIIS -Name 'IISAuth' -Sessionless
  
  Add-PodeRouteGroup -Path '/api' -Routes {
          Enable-PodeOpenApi -Title 'Self Service Catalog API' -Version 0.0.0.1 -RouteFilter '/api/*' -Path '/openapi'
          Enable-PodeOpenApiViewer -Type Swagger -Path '/swagger' -DarkMode -OpenApiUrl '/myService/api/openapi' 
  
          # Test Kerberos authentication
          Add-PodeRoute -Method Get -Path '/test-kerberos' -Authentication 'IISAuth' -ScriptBlock {
              Write-PodeJsonResponse -Value @{ User = $WebEvent.Auth.User }
          }
  }
}

Omzig avatar Aug 05 '22 18:08 Omzig

Hi @Omzig,

Sorry, it's not that you've missed some in the docs, it's that Pode does have support for IIS Application paths, but that logic happens to be missing from Pode's OpenAPI logic. So it'll need adding internally.

Badgerati avatar Aug 06 '22 21:08 Badgerati

So it'll need adding internally.

Thank you for checking on that, can we fix this in the next release? Please and Thank you!

Omzig avatar Aug 11 '22 13:08 Omzig