Skip to content

Add minimalistic support for resolving server variables#523

Closed
slessard wants to merge 4 commits into
getkin:masterfrom
slessard:master
Closed

Add minimalistic support for resolving server variables#523
slessard wants to merge 4 commits into
getkin:masterfrom
slessard:master

Conversation

@slessard

Copy link
Copy Markdown
Contributor

each server variable is replaced with its default value.

@fenollp

fenollp commented Apr 1, 2022

Copy link
Copy Markdown
Collaborator

Continuing discussion from #367 (comment) here:

--- FAIL: TestRouter (0.00s)
    router_test.go:93: 'GET https://domain0.domain1.com/api/v1/hello': should have returned an operation, but it returned an error: no matching operation was found

This is because with your patch

	doc.Servers = []*openapi3.Server{
		{URL: "https://www.example.com/api/v1"},
		{URL: "{scheme}://{d0}.{d1}.com/api/v1/", Variables: map[string]*openapi3.ServerVariable{
			"d0":     {Default: "www"},
			"d1":     {Default: "example", Enum: []string{"example"}},
			"scheme": {Default: "https", Enum: []string{"https", "http"}},
		}},
	}

d0 and d1 get set to their defaults and thus

	expect(r, http.MethodGet, "https://domain0.domain1.com/api/v1/hello", helloGET, map[string]string{
		"d0": "domain0",
		"d1": "domain1",
	})

the given URL "https://domain0.domain1.com/api/v1/hello" cannot match that host.

@slessard

slessard commented Apr 8, 2022

Copy link
Copy Markdown
Contributor Author

I've closed this pull request in favor of the solution that is being worked on in #524

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants