Skip to content

Commit

Permalink
generate openapi spec file
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkasun committed Sep 19, 2023
1 parent b72c42b commit fcb520d
Show file tree
Hide file tree
Showing 14 changed files with 2,649 additions and 1,837 deletions.
2 changes: 2 additions & 0 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func HandleAuthCallback(w http.ResponseWriter, r *http.Request) {
//
// Security:
// oauth
// Responses:
// 200: okResponse
func HandleAuthLogin(w http.ResponseWriter, r *http.Request) {
if auth_provider == nil {
handleOauthNotConfigured(w)
Expand Down
6 changes: 4 additions & 2 deletions controllers/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func dnsHandlers(r *mux.Router) {
//
// Security:
// oauth
// Responses:
// 200: dnsResponse
func getNodeDNS(w http.ResponseWriter, r *http.Request) {

w.Header().Set("Content-Type", "application/json")
Expand Down Expand Up @@ -264,8 +266,8 @@ func GetDNSEntry(domain string, network string) (models.DNSEntry, error) {
// oauth
//
// Responses:
// 200: dnsStringJSONResponse
// *: dnsStringJSONResponse
// 200: dnsResponse
// *: dnsResponse
func pushDNS(w http.ResponseWriter, r *http.Request) {
// Set header
w.Header().Set("Content-Type", "application/json")
Expand Down
206 changes: 142 additions & 64 deletions controllers/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Schemes: https
// BasePath: /
// Version: 0.21.1
// Host: netmaker.io
// Host: api.demo.netmaker.io
//
// Consumes:
// - application/json
Expand All @@ -26,15 +26,37 @@
package controller

import (
serverconfigpkg "github.com/gravitl/netmaker/config"
"os"

"github.com/gravitl/netmaker/config"
"github.com/gravitl/netmaker/logic/acls"
"github.com/gravitl/netmaker/models"
)

var _ = useUnused() // "use" the function to prevent "unused function" errors

// swagger:parameters getFile
type filenameToGet struct {

Check failure on line 39 in controllers/docs.go

View workflow job for this annotation

GitHub Actions / staticcheck

type filenameToGet is unused (U1000)
// Filename
// in: path
// required: true
Filename string `json:"filename"`
}

// swagger:response hasAdmin
type hasAdmin struct {
// in: body
Admin bool
}

// swagger:response apiHostResponse
type apiHostResponse struct {
// in: body
Host models.ApiHost
}

// swagger:parameters getNodeDNS getCustomDNS getDNS
type dnsPathParams struct {
type dnsNetworkPathParam struct {

Check failure on line 59 in controllers/docs.go

View workflow job for this annotation

GitHub Actions / staticcheck

type dnsNetworkPathParam is unused (U1000)
// Network
// in: path
Network string `json:"network"`
Expand All @@ -45,7 +67,6 @@ type dnsParams struct {
// Network
// in: path
Network string `json:"network"`

// DNS Entry
// in: body
Body []models.DNSEntry `json:"body"`
Expand Down Expand Up @@ -76,6 +97,18 @@ type stringJSONResponse struct {
Response string `json:"response"`
}

//swagger:response EnrollmentKey
type EnrollmentKey struct {
// in: body
EnrollmentKey models.EnrollmentKey
}

//swagger:response EnrollmentKeys
type EnrollmentKeys struct {
// in: body
EnrollmentKeys []models.EnrollmentKey
}

// swagger:parameters getAllExtClients
type getAllClientsRequest struct {
// Networks
Expand All @@ -97,19 +130,37 @@ type extClientResponse struct {
ExtClient models.ExtClient `json:"ext_client"`
}

// swagger:response fileResponse
type fileResponse struct {
// in: body
File os.File
}

// swagger:response successResponse
type successResponse struct {
// Success Response
// in: body
SuccessResponse models.SuccessResponse `json:"success_response"`
}

// swagger:parameters getExtClientConf
type extClientConfParams struct {
// Client ID
// in: path
ClientID string `json:"clientid"`
// Network
// in: path
Network string `json:"network"`
// Type
// in: path
Type string `json:"type"`
}

// swagger:parameters getExtClient getExtClientConf updateExtClient deleteExtClient
type extClientPathParams struct {
// Client ID
// in: path
ClientID string `json:"clientid"`

// Network
// in: path
Network string `json:"network"`
Expand Down Expand Up @@ -137,20 +188,17 @@ type createExtClientPathParams struct {

// Node ID
// in: path
NodeID string `json:"node"`
NodeID string `json:"nodeid"`

// Custom ExtClient
// in: body
CustomExtClient models.CustomExtClient `json:"custom_ext_client"`
}

// swagger:parameters getNode updateNode deleteNode createRelay deleteRelay createEgressGateway deleteEgressGateway createIngressGateway deleteIngressGateway uncordonNode
// swagger:parameters getNode updateNode deleteNode createRelay deleteRelay createEgressGateway deleteEgressGateway createIngressGateway deleteIngressGateway ingressGatewayUsers
type networkNodePathParams struct {
// Network
// in: path
Network string `json:"network"`

// Node ID
// in: path
NodeID string `json:"nodeid"`
}
Expand All @@ -161,11 +209,11 @@ type byteArrayResponse struct {
ByteArray []byte `json:"byte_array"`
}

// swagger:parameters getNetworks
type headerNetworks struct {
// name: networks
// in: header
Networks []string `json:"networks"`
// swagger:parameters getNetwork deleteNetwork getNetworkACL updateNetworkACL getNetworkNodes
type NetworkParam struct {
// name: network name
// in: path
Networkname string `json:"networkname"`
}

// swagger:response getNetworksSliceResponse
Expand All @@ -175,25 +223,25 @@ type getNetworksSliceResponse struct {
Networks []models.Network `json:"networks"`
}

// swagger:response hostPull
type hostPull struct {
// hostPull
// in: body
HostPull models.HostPull
}

// swagger:parameters createNetwork updateNetwork
type networkBodyParam struct {
// Network
// in: body
Network models.Network `json:"network"`
}

// swagger:parameters updateNetwork getNetwork updateNetwork updateNetworkNodeLimit deleteNetwork keyUpdate createAccessKey getAccessKeys deleteAccessKey updateNetworkACL getNetworkACL
// swagger:parameters updateNetwork updateNetwork updateNetworkNodeLimit deleteNetwork keyUpdate createAccessKey getAccessKeys updateNetworkACL getNetworkACL
type networkPathParam struct {
// Network Name
// in: path
NetworkName string `json:"networkname"`
}

// swagger:parameters deleteAccessKey
type networkAccessKeyNamePathParam struct {
// Access Key Name
// Network
// in: path
AccessKeyName string `json:"access_key_name"`
network string

Check failure on line 244 in controllers/docs.go

View workflow job for this annotation

GitHub Actions / staticcheck

field network is unused (U1000)
}

// swagger:response networkBodyResponse
Expand Down Expand Up @@ -238,6 +286,15 @@ type nodeBodyParam struct {
Node models.LegacyNode `json:"node"`
}

//swagger:response okResponse
type okRespone struct{}

// swagger:response RegisterResponse
type RegisterResponse struct {
// in: body
RegisterResponse models.RegisterResponse
}

// swagger:parameters createRelay
type relayRequestBodyParam struct {
// Relay Request
Expand All @@ -252,53 +309,75 @@ type egressGatewayBodyParam struct {
EgressGatewayRequest models.EgressGatewayRequest `json:"egress_gateway_request"`
}

// swagger:parameters attachUserToRemoteAccessGateway removeUserFromRemoteAccessGW getUserRemoteAccessGws
type RemoteAccessGatewayUser struct {
// in: path
Username string `json:"username"`
}

// swagger:parameters authenticate
type authParamBodyParam struct {
// network
// in: path
Network string `json:"network"`
// AuthParams
// in: body
AuthParams models.AuthParams `json:"auth_params"`
}

// swagger:response serverConfigResponse
type serverConfigResponse struct {
// Server Config
// swagger:response signal
type signal struct {
// in: body
ServerConfig serverconfigpkg.ServerConfig `json:"server_config"`
Signal models.Signal
}

// swagger:response nodeGetResponse
type nodeGetResponse struct {
// Node Get
// in: body
NodeGet models.NodeGet `json:"node_get"`
// swagger:parameters synchost deleteHost updateHost signalPeer updateKeys
type HostID struct {
// HostID
// in: path
HostID string `json:"hostid"`
}

// swagger:response nodeLastModifiedResponse
type nodeLastModifiedResponse struct {
// Node Last Modified
// in: body
NodesLastModified int64 `json:"nodes_last_modified"`
// swagger:parameters addHostToNetwork deleteHostFromNetwork
type hostFromNetworkParams struct {

Check failure on line 342 in controllers/docs.go

View workflow job for this annotation

GitHub Actions / staticcheck

type hostFromNetworkParams is unused (U1000)
// hostid to add or delete from network
// in: path
HostID string `json:"hostid"`
// network
// in: path
Network string `json:"network"`
}

// swagger:parameters register
//type registerRequestBodyParam struct {
// // Register Request
// // in: body
// RegisterRequest config.RegisterRequest `json:"register_request"`
//}
//
//// swagger:response registerResponse
//type registerResponse struct {
// // Register Response
// // in: body
// RegisterResponse config.RegisterResponse `json:"register_response"`
//}
// swagger:parameters deleteEnrollmentKey
type deleteEnrollmentKeyParam struct {

Check failure on line 352 in controllers/docs.go

View workflow job for this annotation

GitHub Actions / staticcheck

type deleteEnrollmentKeyParam is unused (U1000)
// in: path
KeyID string `json:"keyid"`
}

// swagger:parameters getEnrollmentKey createEnrollmentKey
type token struct {

Check failure on line 358 in controllers/docs.go

View workflow job for this annotation

GitHub Actions / staticcheck

type token is unused (U1000)
// token
// in: path
token string
}

// swagger:response boolResponse
type boolResponse struct {
// Boolean Response
// swagger:parameters handleHostRegister
type registerParams struct {

Check failure on line 365 in controllers/docs.go

View workflow job for this annotation

GitHub Actions / staticcheck

type registerParams is unused (U1000)
// in: path
Token string `json:"token"`
// in: body
Host models.Host `json:"host"`
}

// swagger:response serverConfigResponse
type serverConfigResponse struct {
// Server Config
// in: body
BoolResponse bool `json:"bool_response"`
// example
//{
//"mqusername": "xxxxxxx"
//}
ServerConfig config.ServerConfig `json:"server_config"`
}

// swagger:parameters createAdmin updateUser updateUserNetworks createUser
Expand Down Expand Up @@ -331,7 +410,6 @@ type usernamePathParam struct {

// prevent issues with integration tests for types just used by Swagger docs.
func useUnused() bool {
_ = dnsPathParams{}
_ = dnsParams{}
_ = dnsResponse{}
_ = dnsDeletePathParams{}
Expand All @@ -346,11 +424,9 @@ func useUnused() bool {
_ = createExtClientPathParams{}
_ = networkNodePathParams{}
_ = byteArrayResponse{}
_ = headerNetworks{}
_ = getNetworksSliceResponse{}
_ = networkBodyParam{}
_ = networkPathParam{}
_ = networkAccessKeyNamePathParam{}
_ = networkBodyResponse{}
_ = aclContainerBodyParam{}
_ = aclContainerResponse{}
Expand All @@ -361,14 +437,16 @@ func useUnused() bool {
_ = egressGatewayBodyParam{}
_ = authParamBodyParam{}
_ = serverConfigResponse{}
_ = nodeGetResponse{}
_ = nodeLastModifiedResponse{}
// _ = registerRequestBodyParam{}
// _ = registerResponse{}
_ = boolResponse{}
_ = userBodyParam{}
_ = userBodyResponse{}
_ = userAuthBodyParam{}
_ = usernamePathParam{}
_ = hasAdmin{}
_ = apiHostResponse{}
_ = fileResponse{}
_ = extClientConfParams{}
_ = hostPull{}
_ = okRespone{}
_ = signal{}
return false
}
Loading

0 comments on commit fcb520d

Please sign in to comment.