Skip to content

Commit 1bce9dc

Browse files
committed
🎨 Fixed golint issues.
1 parent 0d8acce commit 1bce9dc

File tree

7 files changed

+61
-6
lines changed

7 files changed

+61
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
![GolangCI](https://github.com/go-oas/docs/workflows/golangci/badge.svg?branch=main)
88
![Build](https://github.com/go-oas/docs/workflows/Build/badge.svg?branch=main)
9-
[![Version](https://img.shields.io/badge/version-v1.0.3-success.svg)](https://github.com/go-oas/docs/releases)
9+
[![Version](https://img.shields.io/badge/version-v1.0.4-success.svg)](https://github.com/go-oas/docs/releases)
1010
[![Go Report Card](https://goreportcard.com/badge/github.com/go-oas/docs)](https://goreportcard.com/report/github.com/go-oas/docs)
1111
[![Coverage Status](https://coveralls.io/repos/github/go-oas/docs/badge.svg?branch=main)](https://coveralls.io/github/go-oas/docs?branch=main)
1212
[![codebeat badge](https://codebeat.co/badges/32b86556-84e3-4db9-9f11-923d12994f90)](https://codebeat.co/projects/github-com-go-oas-docs-main)

annotations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (o *OAS) mapDocAnnotations(path string) error {
132132
}
133133

134134
func mapIfLineContainsOASTag(lineText string, o *OAS) {
135-
if strings.Contains(lineText, OASAnnotationInit) {
135+
if strings.Contains(lineText, oasAnnotationInit) {
136136
annotations := oasAnnotations(strings.Fields(lineText))
137137

138138
var newRoute Path

caller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
// routePostfix will get exported by v1.3.
88
const routePostfix = "Route"
99

10+
// Call is used init registered functions that already exist in the *OAS, and return results if there are any.
1011
func (o *OAS) Call(name string, params ...interface{}) (result []reflect.Value) {
1112
f := reflect.ValueOf(o.RegisteredRoutes[name])
1213

models.go

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package docs
22

3+
// WARNING:
4+
// Most structures in here are an representation of what is defined in default
5+
// Open API Specification documentation, v3.0.3.
6+
//
7+
// [More about it can be found on this link](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md)
8+
9+
// New returns a new instance of OAS structure.
310
func New() OAS {
411
initRoutes := RegRoutes{}
512

@@ -9,7 +16,7 @@ func New() OAS {
916
}
1017

1118
const (
12-
OASAnnotationInit = "// @OAS "
19+
oasAnnotationInit = "// @OAS "
1320
)
1421

1522
// OAS - represents Open API Specification structure, in its approximated Go form.
@@ -24,13 +31,18 @@ type OAS struct {
2431
RegisteredRoutes RegRoutes `yaml:"-"`
2532
}
2633

27-
// Version is represented in SemVer format.
2834
type (
29-
Version string
30-
URL string
35+
// Version represents a SemVer version.
36+
Version string
37+
38+
// URL represents and URL which is casted from string.
39+
URL string
40+
41+
// OASVersion represents the OpenAPISpecification version which will be used.
3142
OASVersion Version
3243
)
3344

45+
// Info represents OAS info object.
3446
type Info struct {
3547
Title string `yaml:"title"`
3648
Description string `yaml:"description"`
@@ -40,36 +52,47 @@ type Info struct {
4052
Version Version `yaml:"version"`
4153
}
4254

55+
// Contact represents OAS contact object, used by Info.
4356
type Contact struct {
4457
Email string `yaml:"email"`
4558
}
4659

60+
// License represents OAS license object, used by Info.
4761
type License struct {
4862
Name string `yaml:"name"`
4963
URL URL `yaml:"url"`
5064
}
5165

66+
// ExternalDocs represents OAS externalDocs object.
67+
//
68+
// Aside from base OAS structure, this is also used by Tag object.
5269
type ExternalDocs struct {
5370
Description string `yaml:"description"`
5471
URL URL `yaml:"url"`
5572
}
5673

74+
// Servers is a slice of Server objects.
5775
type Servers []Server
5876

77+
// Server represents OAS server object.
5978
type Server struct {
6079
URL URL `yaml:"url"`
6180
}
6281

82+
// Tags is a slice of Tag objects.
6383
type Tags []Tag
6484

85+
// Tag represents OAS tag object.
6586
type Tag struct {
6687
Name string `yaml:"name"`
6788
Description string `yaml:"description"`
6889
ExternalDocs ExternalDocs `yaml:"externalDocs"`
6990
}
7091

92+
// Paths is a slice of Path objects.
7193
type Paths []Path
7294

95+
// Path represents OAS path object.
7396
type Path struct {
7497
Route string `yaml:"route"`
7598
HTTPMethod string `yaml:"httpMethod"`
@@ -82,43 +105,54 @@ type Path struct {
82105
HandlerFuncName string `yaml:"-"`
83106
}
84107

108+
// RequestBody represents OAS requestBody object, used by Path.
85109
type RequestBody struct {
86110
Description string `yaml:"description"`
87111
Content ContentTypes `yaml:"content"`
88112
Required bool `yaml:"required"`
89113
}
90114

115+
// ContentTypes is a slice of ContentType objects.
91116
type ContentTypes []ContentType
92117

118+
// ContentType represents OAS content type object, used by RequestBody and Response.
93119
type ContentType struct {
94120
Name string `yaml:"ct-name"` // e.g. application/json
95121
Schema string `yaml:"ct-schema"` // e.g. $ref: '#/components/schemas/Pet'
96122
}
97123

124+
// Responses is a slice of Response objects.
98125
type Responses []Response
99126

127+
// Response represents OAS response object, used by Path.
100128
type Response struct {
101129
Code uint `yaml:"code"`
102130
Description string `yaml:"description"`
103131
Content ContentTypes `yaml:"content"`
104132
}
105133

134+
// SecurityEntities is a slice of Security objects.
106135
type SecurityEntities []Security
107136

137+
// Security represents OAS security object.
108138
type Security struct {
109139
AuthName string
110140
PermTypes []string // write:pets , read:pets etc.
111141
}
112142

143+
// Components is a slice of Component objects.
113144
type Components []Component
114145

146+
// Component represents OAS component object.
115147
type Component struct {
116148
Schemas Schemas `yaml:"schemas"`
117149
SecuritySchemes SecuritySchemes `yaml:"securitySchemes"`
118150
}
119151

152+
// Schemas is a slice of Schema objects.
120153
type Schemas []Schema
121154

155+
// Schema represents OAS schema object, used by Component.
122156
type Schema struct {
123157
Name string
124158
Type string
@@ -127,11 +161,15 @@ type Schema struct {
127161
Ref string // $ref: '#/components/schemas/Pet' // TODO: Should this be omitted if empty?
128162
}
129163

164+
// XMLEntry represents name of XML entry in Schema object.
130165
type XMLEntry struct {
131166
Name string
132167
}
168+
169+
// SchemaProperties is a slice of SchemaProperty objects.
133170
type SchemaProperties []SchemaProperty
134171

172+
// SchemaProperty represents OAS schema object, used by Schema.
135173
type SchemaProperty struct {
136174
Name string `yaml:"-"`
137175
Type string // OAS3.0 data types - e.g. integer, boolean, string
@@ -141,30 +179,37 @@ type SchemaProperty struct {
141179
Default interface{} `yaml:"default,omitempty"`
142180
}
143181

182+
// SecuritySchemes is a slice of SecuritySchemes objects.
144183
type SecuritySchemes []SecurityScheme
145184

185+
// SecurityScheme represents OAS security object, used by Component.
146186
type SecurityScheme struct {
147187
Name string `yaml:"name,omitempty"`
148188
Type string `yaml:"type,omitempty"`
149189
In string `yaml:"in,omitempty"`
150190
Flows SecurityFlows `yaml:"flows,omitempty"`
151191
}
152192

193+
// SecurityFlows is a slice of SecurityFlow objects.
153194
type SecurityFlows []SecurityFlow
154195

196+
// SecurityFlow represents OAS Flows object, used by SecurityScheme.
155197
type SecurityFlow struct {
156198
Type string `yaml:"type,omitempty"`
157199
AuthURL URL `yaml:"authorizationUrl,omitempty"`
158200
Scopes SecurityScopes `yaml:"scopes,omitempty"`
159201
}
160202

203+
// SecurityScopes is a slice of SecurityScope objects.
161204
type SecurityScopes []SecurityScope
162205

206+
// SecurityScope represents OAS SecurityScope object, used by SecurityFlow.
163207
type SecurityScope struct {
164208
Name string `yaml:"name,omitempty"`
165209
Description string `yaml:"description,omitempty"`
166210
}
167211

212+
// isEmpty checks if *ExternalDocs struct is empty.
168213
func (ed *ExternalDocs) isEmpty() bool {
169214
if ed == nil {
170215
return true

routing.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ type (
1616
RegRoutes map[string]RouteFn
1717
)
1818

19+
// AttachRoutes if used for attaching pre-defined API documentation routes.
20+
//
21+
// fns param is a slice of functions that satisfy RouteFn signature.
1922
func (o *OAS) AttachRoutes(fns []RouteFn) {
2023
for _, fn := range fns {
2124
fnDeclaration := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
@@ -26,10 +29,12 @@ func (o *OAS) AttachRoutes(fns []RouteFn) {
2629
}
2730
}
2831

32+
// GetRegisteredRoutes returns a map of registered RouteFn functions - in layman terms "routes".
2933
func (o *OAS) GetRegisteredRoutes() RegRoutes {
3034
return o.RegisteredRoutes
3135
}
3236

37+
// GetPathByIndex returns ptr to Path structure, by its index in the parent struct of OAS.
3338
func (o *OAS) GetPathByIndex(index int) *Path {
3439
return &o.Paths[index]
3540
}

server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const (
2020
sigContSleeperMilliseconds = 20
2121
)
2222

23+
// ConfigSwaggerUI represents a structure which will be used to pass required configuration params to
24+
// the ServeSwaggerUI func.
2325
type ConfigSwaggerUI struct {
2426
Route string
2527
Port string

setters.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func (i *Info) SetLicense(licType, url string) {
2323
}
2424
}
2525

26+
// SetTag is used to define a new tag based on input params, and append it to the slice of tags its being called from.
2627
func (tt *Tags) SetTag(name, tagDescription string, extDocs ExternalDocs) {
2728
var tag Tag
2829

@@ -41,6 +42,7 @@ func (tt *Tags) SetTag(name, tagDescription string, extDocs ExternalDocs) {
4142
tt.AppendTag(&tag)
4243
}
4344

45+
// AppendTag is used to append an Tag to the slice of Tags its being called from.
4446
func (tt *Tags) AppendTag(tag *Tag) {
4547
*tt = append(*tt, *tag)
4648
}

0 commit comments

Comments
 (0)