cancel
Showing results for 
Search instead for 
Did you mean: 

UriFormatException on querying auto-generated asp.net-core server

Highlighted
Occasional Visitor

UriFormatException on querying auto-generated asp.net-core server

I am trying to get the most basic of OpenAPI server to work. It works as expected with auto-generated python-flask server but not with aspnet-core server. Exceptions are being raised on queries.

 

What extra steps are required to get the aspnet server to respond correctly to queries?

 

The YAML is as below:

 

openapi: 3.0.0
info:
  title: Test API
  version: 0.0.0  
servers:
  - url: http://localhost:{port}
    description: Local server
    variables:
      port:
        default: "8092"    
paths:
  /things:
    get:
      summary: Return a list of Things
      responses:
        '200':
          description: A JSON array of Things
          content:
            application/json:
              schema: 
                type: array
                items: 
                  $ref: "#/components/schemas/Thing" 
components:
  schemas:
    Thing:
      properties:
        id:
          type: integer
        name:
          type: string

 

 

On querying http://localhost:8092/things the following error is reported

 

info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\jonathan.noble\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Hosting environment: Development
Content root path: D:\aspnetcore-server-generated\src\IO.Swagger
Now listening on: http://localhost:8092
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost:8092/things
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HM46UOD2UM1E", Request id "0HM46UOD2UM1E:00000001": An unhandled exception was thrown by the application.
System.UriFormatException: Invalid URI: The URI is empty.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at IO.Swagger.Startup.<ConfigureServices>b__5_2(SwaggerGenOptions c) in D:\aspnetcore-server-generated\src\IO.Swagger\Startup.cs:line 73
   at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(String name, TOptions options)
...

 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors