Skip to content

Server URL ignored in $schema field for default configuration #674

@baderj

Description

@baderj

I'm using the default configuration

        config := huma.DefaultConfig("Example API", "1.0.0")

and changed the server url as follows

	config.Servers = []*huma.Server{
		{URL: "https://api.example.com", Description: "Root URL of the API"},
	}

This URL is correctly reflected in the generated documentation, both for the example requests and also in the $schema of the response:

image

However, when requesting the API, the $schema-url is build from ctx.Host() and the listening port, which in my case is localhost:8888

 curl -s "https://api.example.com/test | jq | head
{
  "$schema": "http://localhost:8888/api/v1/schemas/Test.json",
  "data": [
    ...
  ]
}

Shouldn't the $schema in the responses also use the configured server?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions