@@ -164,13 +164,13 @@ func New(doc *spec.Swagger) *Spec {
164164 return a
165165}
166166
167- // SecurityRequirement is a representation of a security requirement for an operation
167+ // SecurityRequirement is a representation of a security requirement for an operation.
168168type SecurityRequirement struct {
169169 Name string
170170 Scopes []string
171171}
172172
173- // SecurityRequirementsFor gets the security requirements for the operation
173+ // SecurityRequirementsFor gets the security requirements for the operation.
174174func (s * Spec ) SecurityRequirementsFor (operation * spec.Operation ) [][]SecurityRequirement {
175175 if s .spec .Security == nil && operation .Security == nil {
176176 return nil
@@ -204,7 +204,7 @@ func (s *Spec) SecurityRequirementsFor(operation *spec.Operation) [][]SecurityRe
204204 return result
205205}
206206
207- // SecurityDefinitionsForRequirements gets the matching security definitions for a set of requirements
207+ // SecurityDefinitionsForRequirements gets the matching security definitions for a set of requirements.
208208func (s * Spec ) SecurityDefinitionsForRequirements (requirements []SecurityRequirement ) map [string ]spec.SecurityScheme {
209209 result := make (map [string ]spec.SecurityScheme )
210210
@@ -219,7 +219,7 @@ func (s *Spec) SecurityDefinitionsForRequirements(requirements []SecurityRequire
219219 return result
220220}
221221
222- // SecurityDefinitionsFor gets the matching security definitions for a set of requirements
222+ // SecurityDefinitionsFor gets the matching security definitions for a set of requirements.
223223func (s * Spec ) SecurityDefinitionsFor (operation * spec.Operation ) map [string ]spec.SecurityScheme {
224224 requirements := s .SecurityRequirementsFor (operation )
225225 if len (requirements ) == 0 {
@@ -250,7 +250,7 @@ func (s *Spec) SecurityDefinitionsFor(operation *spec.Operation) map[string]spec
250250 return result
251251}
252252
253- // ConsumesFor gets the mediatypes for the operation
253+ // ConsumesFor gets the mediatypes for the operation.
254254func (s * Spec ) ConsumesFor (operation * spec.Operation ) []string {
255255 if len (operation .Consumes ) == 0 {
256256 cons := make (map [string ]struct {}, len (s .spec .Consumes ))
@@ -269,7 +269,7 @@ func (s *Spec) ConsumesFor(operation *spec.Operation) []string {
269269 return s .structMapKeys (cons )
270270}
271271
272- // ProducesFor gets the mediatypes for the operation
272+ // ProducesFor gets the mediatypes for the operation.
273273func (s * Spec ) ProducesFor (operation * spec.Operation ) []string {
274274 if len (operation .Produces ) == 0 {
275275 prod := make (map [string ]struct {}, len (s .spec .Produces ))
@@ -400,7 +400,7 @@ func (s *Spec) SafeParamsFor(method, path string, callmeOnError ErrorOnParamFunc
400400 return res
401401}
402402
403- // OperationForName gets the operation for the given id
403+ // OperationForName gets the operation for the given id.
404404func (s * Spec ) OperationForName (operationID string ) (string , string , * spec.Operation , bool ) {
405405 for method , pathItem := range s .operations {
406406 for path , op := range pathItem {
@@ -413,7 +413,7 @@ func (s *Spec) OperationForName(operationID string) (string, string, *spec.Opera
413413 return "" , "" , nil , false
414414}
415415
416- // OperationFor the given method and path
416+ // OperationFor the given method and path.
417417func (s * Spec ) OperationFor (method , path string ) (* spec.Operation , bool ) {
418418 if mp , ok := s .operations [strings .ToUpper (method )]; ok {
419419 op , fn := mp [path ]
@@ -424,12 +424,12 @@ func (s *Spec) OperationFor(method, path string) (*spec.Operation, bool) {
424424 return nil , false
425425}
426426
427- // Operations gathers all the operations specified in the spec document
427+ // Operations gathers all the operations specified in the spec document.
428428func (s * Spec ) Operations () map [string ]map [string ]* spec.Operation {
429429 return s .operations
430430}
431431
432- // AllPaths returns all the paths in the swagger spec
432+ // AllPaths returns all the paths in the swagger spec.
433433func (s * Spec ) AllPaths () map [string ]spec.PathItem {
434434 if s .spec == nil || s .spec .Paths == nil {
435435 return nil
@@ -438,7 +438,7 @@ func (s *Spec) AllPaths() map[string]spec.PathItem {
438438 return s .spec .Paths .Paths
439439}
440440
441- // OperationIDs gets all the operation ids based on method an dpath
441+ // OperationIDs gets all the operation ids based on method an dpath.
442442func (s * Spec ) OperationIDs () []string {
443443 if len (s .operations ) == 0 {
444444 return nil
@@ -458,7 +458,7 @@ func (s *Spec) OperationIDs() []string {
458458 return result
459459}
460460
461- // OperationMethodPaths gets all the operation ids based on method an dpath
461+ // OperationMethodPaths gets all the operation ids based on method an dpath.
462462func (s * Spec ) OperationMethodPaths () []string {
463463 if len (s .operations ) == 0 {
464464 return nil
@@ -474,22 +474,22 @@ func (s *Spec) OperationMethodPaths() []string {
474474 return result
475475}
476476
477- // RequiredConsumes gets all the distinct consumes that are specified in the specification document
477+ // RequiredConsumes gets all the distinct consumes that are specified in the specification document.
478478func (s * Spec ) RequiredConsumes () []string {
479479 return s .structMapKeys (s .consumes )
480480}
481481
482- // RequiredProduces gets all the distinct produces that are specified in the specification document
482+ // RequiredProduces gets all the distinct produces that are specified in the specification document.
483483func (s * Spec ) RequiredProduces () []string {
484484 return s .structMapKeys (s .produces )
485485}
486486
487- // RequiredSecuritySchemes gets all the distinct security schemes that are specified in the swagger spec
487+ // RequiredSecuritySchemes gets all the distinct security schemes that are specified in the swagger spec.
488488func (s * Spec ) RequiredSecuritySchemes () []string {
489489 return s .structMapKeys (s .authSchemes )
490490}
491491
492- // SchemaRef is a reference to a schema
492+ // SchemaRef is a reference to a schema.
493493type SchemaRef struct {
494494 Name string
495495 Ref spec.Ref
@@ -498,7 +498,7 @@ type SchemaRef struct {
498498}
499499
500500// SchemasWithAllOf returns schema references to all schemas that are defined
501- // with an allOf key
501+ // with an allOf key.
502502func (s * Spec ) SchemasWithAllOf () (result []SchemaRef ) {
503503 for _ , v := range s .allOfs {
504504 result = append (result , v )
@@ -507,7 +507,7 @@ func (s *Spec) SchemasWithAllOf() (result []SchemaRef) {
507507 return
508508}
509509
510- // AllDefinitions returns schema references for all the definitions that were discovered
510+ // AllDefinitions returns schema references for all the definitions that were discovered.
511511func (s * Spec ) AllDefinitions () (result []SchemaRef ) {
512512 for _ , v := range s .allSchemas {
513513 result = append (result , v )
@@ -516,7 +516,7 @@ func (s *Spec) AllDefinitions() (result []SchemaRef) {
516516 return
517517}
518518
519- // AllDefinitionReferences returns json refs for all the discovered schemas
519+ // AllDefinitionReferences returns json refs for all the discovered schemas.
520520func (s * Spec ) AllDefinitionReferences () (result []string ) {
521521 for _ , v := range s .references .schemas {
522522 result = append (result , v .String ())
@@ -525,7 +525,7 @@ func (s *Spec) AllDefinitionReferences() (result []string) {
525525 return
526526}
527527
528- // AllParameterReferences returns json refs for all the discovered parameters
528+ // AllParameterReferences returns json refs for all the discovered parameters.
529529func (s * Spec ) AllParameterReferences () (result []string ) {
530530 for _ , v := range s .references .parameters {
531531 result = append (result , v .String ())
@@ -534,7 +534,7 @@ func (s *Spec) AllParameterReferences() (result []string) {
534534 return
535535}
536536
537- // AllResponseReferences returns json refs for all the discovered responses
537+ // AllResponseReferences returns json refs for all the discovered responses.
538538func (s * Spec ) AllResponseReferences () (result []string ) {
539539 for _ , v := range s .references .responses {
540540 result = append (result , v .String ())
@@ -543,7 +543,7 @@ func (s *Spec) AllResponseReferences() (result []string) {
543543 return
544544}
545545
546- // AllPathItemReferences returns the references for all the items
546+ // AllPathItemReferences returns the references for all the items.
547547func (s * Spec ) AllPathItemReferences () (result []string ) {
548548 for _ , v := range s .references .pathItems {
549549 result = append (result , v .String ())
@@ -564,7 +564,7 @@ func (s *Spec) AllItemsReferences() (result []string) {
564564 return
565565}
566566
567- // AllReferences returns all the references found in the document, with possible duplicates
567+ // AllReferences returns all the references found in the document, with possible duplicates.
568568func (s * Spec ) AllReferences () (result []string ) {
569569 for _ , v := range s .references .allRefs {
570570 result = append (result , v .String ())
@@ -573,7 +573,7 @@ func (s *Spec) AllReferences() (result []string) {
573573 return
574574}
575575
576- // AllRefs returns all the unique references found in the document
576+ // AllRefs returns all the unique references found in the document.
577577func (s * Spec ) AllRefs () (result []spec.Ref ) {
578578 set := make (map [string ]struct {})
579579 for _ , v := range s .references .allRefs {
@@ -592,61 +592,61 @@ func (s *Spec) AllRefs() (result []spec.Ref) {
592592}
593593
594594// ParameterPatterns returns all the patterns found in parameters
595- // the map is cloned to avoid accidental changes
595+ // the map is cloned to avoid accidental changes.
596596func (s * Spec ) ParameterPatterns () map [string ]string {
597597 return cloneStringMap (s .patterns .parameters )
598598}
599599
600600// HeaderPatterns returns all the patterns found in response headers
601- // the map is cloned to avoid accidental changes
601+ // the map is cloned to avoid accidental changes.
602602func (s * Spec ) HeaderPatterns () map [string ]string {
603603 return cloneStringMap (s .patterns .headers )
604604}
605605
606606// ItemsPatterns returns all the patterns found in simple array items
607- // the map is cloned to avoid accidental changes
607+ // the map is cloned to avoid accidental changes.
608608func (s * Spec ) ItemsPatterns () map [string ]string {
609609 return cloneStringMap (s .patterns .items )
610610}
611611
612612// SchemaPatterns returns all the patterns found in schemas
613- // the map is cloned to avoid accidental changes
613+ // the map is cloned to avoid accidental changes.
614614func (s * Spec ) SchemaPatterns () map [string ]string {
615615 return cloneStringMap (s .patterns .schemas )
616616}
617617
618618// AllPatterns returns all the patterns found in the spec
619- // the map is cloned to avoid accidental changes
619+ // the map is cloned to avoid accidental changes.
620620func (s * Spec ) AllPatterns () map [string ]string {
621621 return cloneStringMap (s .patterns .allPatterns )
622622}
623623
624624// ParameterEnums returns all the enums found in parameters
625- // the map is cloned to avoid accidental changes
625+ // the map is cloned to avoid accidental changes.
626626func (s * Spec ) ParameterEnums () map [string ][]any {
627627 return cloneEnumMap (s .enums .parameters )
628628}
629629
630630// HeaderEnums returns all the enums found in response headers
631- // the map is cloned to avoid accidental changes
631+ // the map is cloned to avoid accidental changes.
632632func (s * Spec ) HeaderEnums () map [string ][]any {
633633 return cloneEnumMap (s .enums .headers )
634634}
635635
636636// ItemsEnums returns all the enums found in simple array items
637- // the map is cloned to avoid accidental changes
637+ // the map is cloned to avoid accidental changes.
638638func (s * Spec ) ItemsEnums () map [string ][]any {
639639 return cloneEnumMap (s .enums .items )
640640}
641641
642642// SchemaEnums returns all the enums found in schemas
643- // the map is cloned to avoid accidental changes
643+ // the map is cloned to avoid accidental changes.
644644func (s * Spec ) SchemaEnums () map [string ][]any {
645645 return cloneEnumMap (s .enums .schemas )
646646}
647647
648648// AllEnums returns all the enums found in the spec
649- // the map is cloned to avoid accidental changes
649+ // the map is cloned to avoid accidental changes.
650650func (s * Spec ) AllEnums () map [string ][]any {
651651 return cloneEnumMap (s .enums .allEnums )
652652}
0 commit comments