Skip to content

Change swagger.json url #28

@soundTricker

Description

@soundTricker

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions