Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimalistic support for resolving server variables #523

Closed
wants to merge 4 commits into from

Conversation

slessard
Copy link
Contributor

each server variable is replaced with its default value.

@fenollp
Copy link
Collaborator

fenollp commented Apr 1, 2022

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
Copy link
Contributor Author

slessard commented Apr 8, 2022

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