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

Bug: Paths with "x-" anywhere in a path name do not appear in the Swagger UI #215

Open
Sam-Kearns opened this issue May 13, 2022 · 0 comments

Comments

@Sam-Kearns
Copy link

Sam-Kearns commented May 13, 2022

Bug Description

Any Path that has x- anywhere in the path name does not show up in the Swagger UI. The path does still work in the service if you make a request to it.

Example:

{
	"paths": {
		"/api/example/tax-district": {
			...
		}
	}
}

Cause

The stripVendorExtensions function looks for vendor extensions with the regex  /\x-(.*)/ . This regex matches key names with x- positioned anywhere in the text, and removes them.

I presume that this function is run after the routes are configured (since the endpoint still works), but before the reponse content is assembled for the request from the UI to fetch swagger.json.

Solution

The OpenAPI specification says that vendor extensions are properties that start with x-, so this behavior is a bug.

The regex should be changed to this: /^\x-(.*)/

The added caret at the start causes the regex to only match keys that begin with x-, rather than matching them anywhere in the string

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

No branches or pull requests

1 participant