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

Change swagger.json url #28

Open
soundTricker opened this issue Feb 13, 2019 · 1 comment
Open

Change swagger.json url #28

soundTricker opened this issue Feb 13, 2019 · 1 comment

Comments

@soundTricker
Copy link
Contributor

soundTricker commented Feb 13, 2019

I want to change swagger.json url.

if we can change it, we can have multiple swagger definitions with #27 like below.

	publicSwPlugin := swagger.NewPlugin(&swagger.Options{
                 // SwaggerJSONPath: "/api/swagger.json", this is default
		Object: &swagger.Object{
			Info: &swagger.Info{
				Title:   "Todo list",
				Version: "v1",
			},
			Schemes: []string{"http"},
		},
		DefinitionNameModifier: func(refT reflect.Type, defName string) string {
			if strings.HasSuffix(defName, "JSON") {
				return defName[:len(defName)-4]
			}
			return defName
		},
                IgnoreRoute: func(rd *ucon.RouteDefinition) bool {
		        return strings.HasPrefix(rd.PathTemplate.PathTemplate, "/admin")
	        },
	})
	ucon.Plugin(publicSwPlugin)
	adminSwPlugin := swagger.NewPlugin(&swagger.Options{
                 SwaggerJSONPath: "/admin/api/swagger.json",
		Object: &swagger.Object{
			Info: &swagger.Info{
				Title:   "Todo list",
				Version: "v1",
			},
			Schemes: []string{"http"},
		},
		DefinitionNameModifier: func(refT reflect.Type, defName string) string {
			if strings.HasSuffix(defName, "JSON") {
				return defName[:len(defName)-4]
			}
			return defName
		},
                IgnoreRoute: func(rd *ucon.RouteDefinition) bool {
		        return !strings.HasPrefix(rd.PathTemplate.PathTemplate, "/admin")
	        },
	})
	ucon.Plugin(adminSwPlugin)
@vvakame
Copy link
Contributor

vvakame commented Feb 13, 2019

looks good.

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

2 participants