@@ -13,21 +13,21 @@ import (
1313)
1414
1515var (
16- // ErrGenerateSwagger throws when fails the marshalling of the swagger struct.
17- ErrGenerateSwagger = errors .New ("fail to generate swagger " )
18- // ErrValidatingSwagger throws when given swagger params are not correct.
19- ErrValidatingSwagger = errors .New ("fails to validate swagger " )
16+ // ErrGenerateOAS throws when fails the marshalling of the swagger struct.
17+ ErrGenerateOAS = errors .New ("fail to generate openapi " )
18+ // ErrValidatingOAS throws when given openapi params are not correct.
19+ ErrValidatingOAS = errors .New ("fails to validate openapi " )
2020)
2121
2222const (
23- // DefaultJSONDocumentationPath is the path of the swagger documentation in json format.
23+ // DefaultJSONDocumentationPath is the path of the openapi documentation in json format.
2424 DefaultJSONDocumentationPath = "/documentation/json"
25- // DefaultYAMLDocumentationPath is the path of the swagger documentation in yaml format.
25+ // DefaultYAMLDocumentationPath is the path of the openapi documentation in yaml format.
2626 DefaultYAMLDocumentationPath = "/documentation/yaml"
2727 defaultOpenapiVersion = "3.0.0"
2828)
2929
30- // Router handle the api router and the swagger schema.
30+ // Router handle the api router and the openapi schema.
3131// api router supported out of the box are:
3232// - gorilla mux
3333type Router [HandlerFunc , Route any ] struct {
@@ -55,7 +55,7 @@ type Options struct {
5555func NewRouter [HandlerFunc , Route any ](router apirouter.Router [HandlerFunc , Route ], options Options ) (* Router [HandlerFunc , Route ], error ) {
5656 swagger , err := generateNewValidOpenapi (options .Openapi )
5757 if err != nil {
58- return nil , fmt .Errorf ("%w: %s" , ErrValidatingSwagger , err )
58+ return nil , fmt .Errorf ("%w: %s" , ErrValidatingOAS , err )
5959 }
6060
6161 var ctx = options .Context
@@ -132,18 +132,18 @@ func generateNewValidOpenapi(swagger *openapi3.T) (*openapi3.T, error) {
132132// expose the generated swagger
133133func (r Router [_ , _ ]) GenerateAndExposeOpenapi () error {
134134 if err := r .swaggerSchema .Validate (r .context ); err != nil {
135- return fmt .Errorf ("%w: %s" , ErrValidatingSwagger , err )
135+ return fmt .Errorf ("%w: %s" , ErrValidatingOAS , err )
136136 }
137137
138138 jsonSwagger , err := r .swaggerSchema .MarshalJSON ()
139139 if err != nil {
140- return fmt .Errorf ("%w json marshal: %s" , ErrGenerateSwagger , err )
140+ return fmt .Errorf ("%w json marshal: %s" , ErrGenerateOAS , err )
141141 }
142142 r .router .AddRoute (http .MethodGet , r .jsonDocumentationPath , r .router .SwaggerHandler ("application/json" , jsonSwagger ))
143143
144144 yamlSwagger , err := yaml .JSONToYAML (jsonSwagger )
145145 if err != nil {
146- return fmt .Errorf ("%w yaml marshal: %s" , ErrGenerateSwagger , err )
146+ return fmt .Errorf ("%w yaml marshal: %s" , ErrGenerateOAS , err )
147147 }
148148 r .router .AddRoute (http .MethodGet , r .yamlDocumentationPath , r .router .SwaggerHandler ("text/plain" , yamlSwagger ))
149149
0 commit comments