@@ -14,10 +14,10 @@ import (
1414 "github.com/sv-tools/openapi/spec"
1515)
1616
17- // FieldParserFactory create FieldParser.
17+ // FieldParserFactoryV3 func(ps *Parser, field *ast.Field) FieldParserV3 create FieldParser.
1818type FieldParserFactoryV3 func (ps * Parser , field * ast.Field ) FieldParserV3
1919
20- // FieldParser parse struct field.
20+ // FieldParserV3 parse struct field.
2121type FieldParserV3 interface {
2222 ShouldSkip () bool
2323 FieldName () (string , error )
@@ -28,8 +28,8 @@ type FieldParserV3 interface {
2828}
2929
3030// GetOpenAPI returns *spec.OpenAPI which is the root document object for the API specification.
31- func (parser * Parser ) GetOpenAPI () * spec.OpenAPI {
32- return parser .openAPI
31+ func (p * Parser ) GetOpenAPI () * spec.OpenAPI {
32+ return p .openAPI
3333}
3434
3535func (p * Parser ) parseGeneralAPIInfoV3 (comments []string ) error {
@@ -419,8 +419,8 @@ func getSecurityDefinitionKey(lines []string) string {
419419 return ""
420420}
421421
422- // ParseRouterAPIInfo parses router api info for given astFile.
423- func (parser * Parser ) ParseRouterAPIInfoV3 (fileInfo * AstFileInfo ) error {
422+ // ParseRouterAPIInfoV3 parses router api info for given astFile.
423+ func (p * Parser ) ParseRouterAPIInfoV3 (fileInfo * AstFileInfo ) error {
424424 for _ , astDescription := range fileInfo .File .Decls {
425425 if (fileInfo .ParseFlag & ParseOperations ) == ParseNone {
426426 continue
@@ -431,18 +431,18 @@ func (parser *Parser) ParseRouterAPIInfoV3(fileInfo *AstFileInfo) error {
431431 continue
432432 }
433433
434- if parser .matchTags (astDeclaration .Doc .List ) &&
435- matchExtension (parser .parseExtension , astDeclaration .Doc .List ) {
434+ if p .matchTags (astDeclaration .Doc .List ) &&
435+ matchExtension (p .parseExtension , astDeclaration .Doc .List ) {
436436 // for per 'function' comment, create a new 'Operation' object
437- operation := NewOperationV3 (parser , SetCodeExampleFilesDirectoryV3 (parser .codeExampleFilesDir ))
437+ operation := NewOperationV3 (p , SetCodeExampleFilesDirectoryV3 (p .codeExampleFilesDir ))
438438
439439 for _ , comment := range astDeclaration .Doc .List {
440440 err := operation .ParseComment (comment .Text , fileInfo .File )
441441 if err != nil {
442442 return fmt .Errorf ("ParseComment error in file %s :%+v" , fileInfo .Path , err )
443443 }
444444 }
445- err := processRouterOperationV3 (parser , operation )
445+ err := processRouterOperationV3 (p , operation )
446446 if err != nil {
447447 return err
448448 }
@@ -941,8 +941,8 @@ func (p *Parser) getRefTypeSchemaV3(typeSpecDef *TypeSpecDef, schema *SchemaV3)
941941 return refSchema
942942}
943943
944- // GetSchemaTypePath get path of schema type.
945- func (parser * Parser ) GetSchemaTypePathV3 (schema * spec.RefOrSpec [spec.Schema ], depth int ) []string {
944+ // GetSchemaTypePathV3 get path of schema type.
945+ func (p * Parser ) GetSchemaTypePathV3 (schema * spec.RefOrSpec [spec.Schema ], depth int ) []string {
946946 if schema == nil || depth == 0 {
947947 return nil
948948 }
@@ -955,8 +955,8 @@ func (parser *Parser) GetSchemaTypePathV3(schema *spec.RefOrSpec[spec.Schema], d
955955 if name != "" {
956956 if pos := strings .LastIndexByte (name , '/' ); pos >= 0 {
957957 name = name [pos + 1 :]
958- if schema , ok := parser .openAPI .Components .Spec .Schemas [name ]; ok {
959- return parser .GetSchemaTypePathV3 (schema , depth )
958+ if schema , ok := p .openAPI .Components .Spec .Schemas [name ]; ok {
959+ return p .GetSchemaTypePathV3 (schema , depth )
960960 }
961961 }
962962
@@ -970,15 +970,15 @@ func (parser *Parser) GetSchemaTypePathV3(schema *spec.RefOrSpec[spec.Schema], d
970970
971971 s := []string {schema .Spec .Type [0 ]}
972972
973- return append (s , parser .GetSchemaTypePathV3 (schema .Spec .Items .Schema , depth )... )
973+ return append (s , p .GetSchemaTypePathV3 (schema .Spec .Items .Schema , depth )... )
974974 case OBJECT :
975975 if schema .Spec .AdditionalProperties != nil && schema .Spec .AdditionalProperties .Schema != nil {
976976 // for map
977977 depth --
978978
979979 s := []string {schema .Spec .Type [0 ]}
980980
981- return append (s , parser .GetSchemaTypePathV3 (schema .Spec .AdditionalProperties .Schema , depth )... )
981+ return append (s , p .GetSchemaTypePathV3 (schema .Spec .AdditionalProperties .Schema , depth )... )
982982 }
983983 }
984984
0 commit comments