@@ -558,13 +558,18 @@ func applyTemplate(p param) (string, error) {
558558// will be updated instead. (JSON always gets applied directly to the passed
559559// object.)
560560//
561- // If there is no 'Summary', the same behavior will be attempted on 'Title'.
561+ // If there is no 'Summary', the same behavior will be attempted on 'Title',
562+ // but only if the last character is not a period.
562563//
563564// To apply additional Swagger properties, one can pass valid JSON as described
564565// before. This JSON gets parsed and applied to the passed swaggerObject
565566// directly. This lets users easily apply custom properties such as contact
566567// details, API base path, et al.
567568func updateSwaggerDataFromComments (swaggerObject interface {}, comment string ) error {
569+ if len (comment ) == 0 {
570+ return nil
571+ }
572+
568573 // Find a section containing additional Swagger metadata.
569574 matches := swaggerExtrasRegexp .FindStringSubmatch (comment )
570575
@@ -597,8 +602,10 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) er
597602 // Figure out which properties to update.
598603 summaryValue := infoObjectValue .FieldByName ("Summary" )
599604 descriptionValue := infoObjectValue .FieldByName ("Description" )
605+ usingTitle := false
600606 if ! summaryValue .CanSet () {
601607 summaryValue = infoObjectValue .FieldByName ("Title" )
608+ usingTitle = true
602609 }
603610
604611 // If there is a summary (or summary-equivalent), use the first
@@ -608,16 +615,18 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) er
608615
609616 summary := strings .TrimSpace (paragraphs [0 ])
610617 description := strings .TrimSpace (strings .Join (paragraphs [1 :], "\n \n " ))
611- if len (summary ) > 0 {
612- summaryValue .Set (reflect .ValueOf (summary ))
613- }
614- if len (description ) > 0 {
615- if ! descriptionValue .CanSet () {
616- return fmt .Errorf ("Object that has Summary but no Description?" )
618+ if ! usingTitle || summary [len (summary )- 1 ] != '.' {
619+ if len (summary ) > 0 {
620+ summaryValue .Set (reflect .ValueOf (summary ))
617621 }
618- descriptionValue .Set (reflect .ValueOf (description ))
622+ if len (description ) > 0 {
623+ if ! descriptionValue .CanSet () {
624+ return fmt .Errorf ("Encountered object type with a summary, but no description" )
625+ }
626+ descriptionValue .Set (reflect .ValueOf (description ))
627+ }
628+ return nil
619629 }
620- return nil
621630 }
622631
623632 // There was no summary field on the swaggerObject. Try to apply the
0 commit comments