ginSwagger

package
v1.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: GPL-3.0 Imports: 8 Imported by: 1

README

Greenbone Logo

ginSwagger

provides a safe way to server the SwaggerUI

Reason for implementation

Reason to provide this package is that the https://github.com/swaggo/gin-swagger is actually not using the latest swagger-ui.

To use the latest swagger-ui (by using github.com/swaggo/files/v2) we needed to change the implementation as the gin-swagger package still uses the files in version 1.0

Sources used

To compile the new package we took the gin-echo package (https://github.com/swaggo/echo-swagger/blob/master/swagger.go) as a reference and added the gin based functionality.

Usage

If you need the possibility to authenticate using keycloak you first need to set the OAuthConfig. Then provide this OAuthConfig to the ginSwagger.GinWrapHandler which serves the swagger UI.

Example

authConfig := &ginSwagger.OAuthConfig{
    ClientId: cfg.WebClientName,
    Realm:    cfg.Realm,
    AppName:  "Asset Management Backend",
}

ginSwagger.GinWrapHandler(
    ginSwagger.OAuth(authConfig),
    ginSwagger.InstanceName(""),
)(c)

License

Copyright (C) 2025 [Greenbone AG][Greenbone AG]

Licensed under the GNU General Public License v3.0 or later.

ginSwagger

import "github.com/greenbone/opensight-golang-libraries/pkg/swagger"

Index

Variables

var WrapHandler = GinWrapHandler()

func DeepLinking

func DeepLinking(deepLinking bool) func(*Config)

func DocExpansion

func DocExpansion(docExpansion string) func(*Config)

func DomID

func DomID(domID string) func(*Config)

func GinWrapHandler

func GinWrapHandler(options ...func(*Config)) gin.HandlerFunc

func InstanceName

func InstanceName(instanceName string) func(*Config)

func OAuth

func OAuth(config *OAuthConfig) func(*Config)

func PersistAuthorization

func PersistAuthorization(persistAuthorization bool) func(*Config)

func SyntaxHighlight

func SyntaxHighlight(syntaxHighlight bool) func(*Config)

func URL

func URL(url string) func(*Config)

type Config

Config stores ginSwagger configuration variables.

type Config struct {
    URLs                 []string
    DocExpansion         string
    DomID                string
    InstanceName         string
    DeepLinking          bool
    PersistAuthorization bool
    SyntaxHighlight      bool
    OAuth                *OAuthConfig
}

type OAuthConfig

type OAuthConfig struct {
    ClientId string
    Realm    string
    AppName  string
}

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WrapHandler = GinWrapHandler()

Functions

func DeepLinking

func DeepLinking(deepLinking bool) func(*Config)

func DocExpansion

func DocExpansion(docExpansion string) func(*Config)

func DomID

func DomID(domID string) func(*Config)

func GinWrapHandler

func GinWrapHandler(options ...func(*Config)) gin.HandlerFunc

func InstanceName

func InstanceName(instanceName string) func(*Config)

func OAuth

func OAuth(config *OAuthConfig) func(*Config)

func PersistAuthorization

func PersistAuthorization(persistAuthorization bool) func(*Config)

func SyntaxHighlight

func SyntaxHighlight(syntaxHighlight bool) func(*Config)

func URL

func URL(url string) func(*Config)

Types

type Config

type Config struct {
	URLs                 []string
	DocExpansion         string
	DomID                string
	InstanceName         string
	DeepLinking          bool
	PersistAuthorization bool
	SyntaxHighlight      bool
	OAuth                *OAuthConfig
}

Config stores ginSwagger configuration variables.

type OAuthConfig

type OAuthConfig struct {
	ClientId string
	Realm    string
	AppName  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL