@@ -13,8 +13,6 @@ import (
1313 pbdescriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
1414)
1515
16- var swaggerExtrasRegexp = regexp .MustCompile (`(?s)^(.*[^\s])[\s]*<!-- swagger extras start(.*)swagger extras end -->[\s]*(.*)$` )
17-
1816// findServicesMessagesAndEnumerations discovers all messages and enums defined in the RPC methods of the service.
1917func findServicesMessagesAndEnumerations (s []* descriptor.Service , reg * descriptor.Registry , m messageMap , e enumMap ) {
2018 for _ , svc := range s {
@@ -541,55 +539,20 @@ func applyTemplate(p param) (string, error) {
541539// updateSwaggerDataFromComments updates a Swagger object based on a comment
542540// from the proto file.
543541//
544- // As a first step, a section matching:
545- //
546- // <!-- swagger extras start.*swagger extras end-->
547- //
548- // where .* contains valid JSON will be stored for later processing, and then
549- // removed from the passed string.
550- // (Implementation note: Currently, the JSON gets immediately applied and
551- // thus cannot override summary and description.)
552- //
553542// First paragraph of a comment is used for summary. Remaining paragraphs of a
554543// comment are used for description. If 'Summary' field is not present on the
555544// passed swaggerObject, the summary and description are joined by \n\n.
556545//
557546// If there is a field named 'Info', its 'Summary' and 'Description' fields
558- // will be updated instead. (JSON always gets applied directly to the passed
559- // object.)
547+ // will be updated instead.
560548//
561549// If there is no 'Summary', the same behavior will be attempted on 'Title',
562550// but only if the last character is not a period.
563- //
564- // To apply additional Swagger properties, one can pass valid JSON as described
565- // before. This JSON gets parsed and applied to the passed swaggerObject
566- // directly. This lets users easily apply custom properties such as contact
567- // details, API base path, et al.
568551func updateSwaggerDataFromComments (swaggerObject interface {}, comment string ) error {
569552 if len (comment ) == 0 {
570553 return nil
571554 }
572555
573- // Find a section containing additional Swagger metadata.
574- matches := swaggerExtrasRegexp .FindStringSubmatch (comment )
575-
576- if len (matches ) > 0 {
577- // If found, before further processing, replace the
578- // comment with a version that does not contain the
579- // extras.
580- comment = matches [1 ]
581- if len (matches [3 ]) > 0 {
582- comment += "\n \n " + matches [3 ]
583- }
584-
585- // Parse the JSON and apply it.
586- // TODO(ivucica): apply extras /after/ applying summary
587- // and description.
588- if err := json .Unmarshal ([]byte (matches [2 ]), swaggerObject ); err != nil {
589- return fmt .Errorf ("error: %s, parsing: %s" , err .Error (), matches [2 ])
590- }
591- }
592-
593556 // Figure out what to apply changes to.
594557 swaggerObjectValue := reflect .ValueOf (swaggerObject )
595558 infoObjectValue := swaggerObjectValue .Elem ().FieldByName ("Info" )
0 commit comments