From d78cffc570a67256f7bf3651cd38c3c8c0b838b9 Mon Sep 17 00:00:00 2001 From: EZ4Jam1n <1286884552@qq.com> Date: Fri, 26 Jul 2024 20:17:36 +0800 Subject: [PATCH] fix: golangci-lint --- .../generator/generator.go | 29 +++++----- .../generator/reflector.go | 7 ++- .../generator/wellknown/mediatypes.go | 2 +- .../generator/wellknown/schemas.go | 55 ++++++++++++++----- protoc-gen-http-swagger/main.go | 5 +- .../protobuf/api/httpOption.go | 20 +++---- .../protobuf/openapi/annotations.pb.go | 3 +- .../protobuf/openapi/document.go | 46 ++++++++-------- .../protobuf/openapi/openapi.pb.go | 5 +- 9 files changed, 101 insertions(+), 71 deletions(-) diff --git a/protoc-gen-http-swagger/generator/generator.go b/protoc-gen-http-swagger/generator/generator.go index f713d06..bc72964 100644 --- a/protoc-gen-http-swagger/generator/generator.go +++ b/protoc-gen-http-swagger/generator/generator.go @@ -33,14 +33,15 @@ package generator import ( "fmt" - "github.com/hertz-contrib/swagger-generate/protoc-gen-http-swagger/protobuf/api" - "github.com/hertz-contrib/swagger-generate/protoc-gen-http-swagger/protobuf/openapi" - "google.golang.org/protobuf/runtime/protoimpl" "log" "regexp" "sort" "strings" + "github.com/hertz-contrib/swagger-generate/protoc-gen-http-swagger/protobuf/api" + "github.com/hertz-contrib/swagger-generate/protoc-gen-http-swagger/protobuf/openapi" + "google.golang.org/protobuf/runtime/protoimpl" + "google.golang.org/genproto/googleapis/api/annotations" status_pb "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/protobuf/compiler/protogen" @@ -67,8 +68,10 @@ const ( // In order to dynamically add google.rpc.Status responses we need // to know the message descriptors for google.rpc.Status as well // as google.protobuf.Any. -var statusProtoDesc = (&status_pb.Status{}).ProtoReflect().Descriptor() -var anyProtoDesc = (&any_pb.Any{}).ProtoReflect().Descriptor() +var ( + statusProtoDesc = (&status_pb.Status{}).ProtoReflect().Descriptor() + anyProtoDesc = (&any_pb.Any{}).ProtoReflect().Descriptor() +) // OpenAPIGenerator holds internal state needed to generate an OpenAPIv3 document for a transcoded Protocol Buffer service. type OpenAPIGenerator struct { @@ -255,7 +258,6 @@ func (g *OpenAPIGenerator) filterCommentString(c protogen.Comments) string { } func (g *OpenAPIGenerator) getSchemaByOption(inputMessage *protogen.Message, bodyType *protoimpl.ExtensionInfo) *openapi.Schema { - // Build an array holding the fields of the message. definitionProperties := &openapi.Properties{ AdditionalProperties: make([]*openapi.NamedSchemaOrReference, 0), @@ -345,7 +347,7 @@ func (g *OpenAPIGenerator) getSchemaByOption(inputMessage *protogen.Message, bod schema := &openapi.Schema{ Type: "object", Properties: definitionProperties, - //Required: required, + // Required: required, } // Merge any `Schema` annotations with the current @@ -367,8 +369,8 @@ func (g *OpenAPIGenerator) buildOperation( defaultHost string, path string, inputMessage *protogen.Message, - outputMessage *protogen.Message) (*openapi.Operation, string) { - + outputMessage *protogen.Message, +) (*openapi.Operation, string) { // Parameters array to hold all parameter objects var parameters []*openapi.ParameterOrReference @@ -403,7 +405,7 @@ func (g *OpenAPIGenerator) buildOperation( proto.Merge(schema.Schema, extProperty.(*openapi.Schema)) } } - //按照openapi规范,path参数如果有则一定是required + // 按照openapi规范,path参数如果有则一定是required required = true } else if ext = proto.GetExtension(field.Desc.Options(), api.E_Cookie); ext != "" { paramName = proto.GetExtension(field.Desc.Options(), api.E_Cookie).(string) @@ -501,7 +503,7 @@ func (g *OpenAPIGenerator) buildOperation( RequestBody = &openapi.RequestBodyOrReference{ Oneof: &openapi.RequestBodyOrReference_RequestBody{ RequestBody: &openapi.RequestBody{ - //Required: true, + // Required: true, Content: &openapi.MediaTypes{ AdditionalProperties: additionalProperties, }, @@ -568,7 +570,6 @@ func (g *OpenAPIGenerator) buildOperation( } func (g *OpenAPIGenerator) getResponseForMessage(d *openapi.Document, message *protogen.Message) (string, *openapi.HeadersOrReferences, *openapi.MediaTypes) { - headers := &openapi.HeadersOrReferences{AdditionalProperties: []*openapi.NamedHeaderOrReference{}} for _, field := range message.Fields { @@ -589,7 +590,7 @@ func (g *OpenAPIGenerator) getResponseForMessage(d *openapi.Document, message *p } } - //get api.body、api.raw_body option schema + // get api.body、api.raw_body option schema bodySchema := g.getSchemaByOption(message, api.E_Body) rawBodySchema := g.getSchemaByOption(message, api.E_RawBody) @@ -641,7 +642,7 @@ func (g *OpenAPIGenerator) getResponseForMessage(d *openapi.Document, message *p } // addOperationToDocument adds an operation to the specified path/method. -func (g *OpenAPIGenerator) addOperationToDocument(d *openapi.Document, op *openapi.Operation, path string, methodName string) { +func (g *OpenAPIGenerator) addOperationToDocument(d *openapi.Document, op *openapi.Operation, path, methodName string) { var selectedPathItem *openapi.NamedPathItem for _, namedPathItem := range d.Paths.Path { if namedPathItem.Name == path { diff --git a/protoc-gen-http-swagger/generator/reflector.go b/protoc-gen-http-swagger/generator/reflector.go index 79faa0a..987c501 100644 --- a/protoc-gen-http-swagger/generator/reflector.go +++ b/protoc-gen-http-swagger/generator/reflector.go @@ -32,10 +32,11 @@ package generator import ( - "github.com/hertz-contrib/swagger-generate/protoc-gen-http-swagger/protobuf/openapi" "log" "strings" + "github.com/hertz-contrib/swagger-generate/protoc-gen-http-swagger/protobuf/openapi" + "google.golang.org/protobuf/reflect/protoreflect" wk "github.com/hertz-contrib/swagger-generate/protoc-gen-http-swagger/generator/wellknown" @@ -172,7 +173,9 @@ func (r *OpenAPIReflector) schemaOrReferenceForMessage(message protoreflect.Mess ref := r.schemaReferenceForMessage(message) return &openapi.SchemaOrReference{ Oneof: &openapi.SchemaOrReference_Reference{ - Reference: &openapi.Reference{XRef: ref}}} + Reference: &openapi.Reference{XRef: ref}, + }, + } } } diff --git a/protoc-gen-http-swagger/generator/wellknown/mediatypes.go b/protoc-gen-http-swagger/generator/wellknown/mediatypes.go index a8688c8..0de9507 100644 --- a/protoc-gen-http-swagger/generator/wellknown/mediatypes.go +++ b/protoc-gen-http-swagger/generator/wellknown/mediatypes.go @@ -6,7 +6,7 @@ // // http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, softwis +// Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and diff --git a/protoc-gen-http-swagger/generator/wellknown/schemas.go b/protoc-gen-http-swagger/generator/wellknown/schemas.go index 69c7c9f..565844e 100644 --- a/protoc-gen-http-swagger/generator/wellknown/schemas.go +++ b/protoc-gen-http-swagger/generator/wellknown/schemas.go @@ -6,7 +6,7 @@ // // http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, softwis +// Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and @@ -39,31 +39,41 @@ import ( func NewStringSchema() *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "string"}}} + Schema: &v3.Schema{Type: "string"}, + }, + } } func NewBooleanSchema() *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "boolean"}}} + Schema: &v3.Schema{Type: "boolean"}, + }, + } } func NewBytesSchema() *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "string", Format: "bytes"}}} + Schema: &v3.Schema{Type: "string", Format: "bytes"}, + }, + } } func NewIntegerSchema(format string) *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "integer", Format: format}}} + Schema: &v3.Schema{Type: "integer", Format: format}, + }, + } } func NewNumberSchema(format string) *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "number", Format: format}}} + Schema: &v3.Schema{Type: "number", Format: format}, + }, + } } func NewEnumSchema(enum_type *string, field protoreflect.FieldDescriptor) *v3.SchemaOrReference { @@ -81,7 +91,9 @@ func NewEnumSchema(enum_type *string, field protoreflect.FieldDescriptor) *v3.Sc } return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: schema}} + Schema: schema, + }, + } } func NewListSchema(item_schema *v3.SchemaOrReference) *v3.SchemaOrReference { @@ -100,14 +112,18 @@ func NewListSchema(item_schema *v3.SchemaOrReference) *v3.SchemaOrReference { func NewGoogleApiHttpBodySchema() *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "string"}}} + Schema: &v3.Schema{Type: "string"}, + }, + } } // google.protobuf.Timestamp is serialized as a string func NewGoogleProtobufTimestampSchema() *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "string", Format: "date-time"}}} + Schema: &v3.Schema{Type: "string", Format: "date-time"}, + }, + } } // google.protobuf.Duration is serialized as a string @@ -158,28 +174,36 @@ func NewGoogleProtobufDurationSchema() *v3.SchemaOrReference { func NewGoogleTypeDateSchema() *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "string", Format: "date"}}} + Schema: &v3.Schema{Type: "string", Format: "date"}, + }, + } } // google.type.DateTime is serialized as a string func NewGoogleTypeDateTimeSchema() *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "string", Format: "date-time"}}} + Schema: &v3.Schema{Type: "string", Format: "date-time"}, + }, + } } // google.protobuf.FieldMask masks is serialized as a string func NewGoogleProtobufFieldMaskSchema() *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "string", Format: "field-mask"}}} + Schema: &v3.Schema{Type: "string", Format: "field-mask"}, + }, + } } // google.protobuf.Struct is equivalent to a JSON object func NewGoogleProtobufStructSchema() *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "object"}}} + Schema: &v3.Schema{Type: "object"}, + }, + } } // google.protobuf.Value is handled specially @@ -242,7 +266,7 @@ func NewGoogleProtobufAnySchema(name string) *v3.NamedSchemaOrReference { } // google.rpc.Status is handled specially -func NewGoogleRpcStatusSchema(name string, any_name string) *v3.NamedSchemaOrReference { +func NewGoogleRpcStatusSchema(name, any_name string) *v3.NamedSchemaOrReference { return &v3.NamedSchemaOrReference{ Name: name, Value: &v3.SchemaOrReference{ @@ -308,7 +332,8 @@ func NewGoogleRpcStatusSchema(name string, any_name string) *v3.NamedSchemaOrRef func NewGoogleProtobufMapFieldEntrySchema(value_field_schema *v3.SchemaOrReference) *v3.SchemaOrReference { return &v3.SchemaOrReference{ Oneof: &v3.SchemaOrReference_Schema{ - Schema: &v3.Schema{Type: "object", + Schema: &v3.Schema{ + Type: "object", AdditionalProperties: &v3.AdditionalPropertiesItem{ Oneof: &v3.AdditionalPropertiesItem_SchemaOrReference{ SchemaOrReference: value_field_schema, diff --git a/protoc-gen-http-swagger/main.go b/protoc-gen-http-swagger/main.go index 28349ba..4930838 100644 --- a/protoc-gen-http-swagger/main.go +++ b/protoc-gen-http-swagger/main.go @@ -33,11 +33,12 @@ package main import ( "flag" + "path/filepath" + "strings" + "github.com/hertz-contrib/swagger-generate/protoc-gen-http-swagger/generator" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/types/pluginpb" - "path/filepath" - "strings" ) var flags flag.FlagSet diff --git a/protoc-gen-http-swagger/protobuf/api/httpOption.go b/protoc-gen-http-swagger/protobuf/api/httpOption.go index a6f4d2a..d5a024d 100644 --- a/protoc-gen-http-swagger/protobuf/api/httpOption.go +++ b/protoc-gen-http-swagger/protobuf/api/httpOption.go @@ -22,17 +22,15 @@ import ( "google.golang.org/protobuf/runtime/protoimpl" ) -var ( - HttpMethodOptions = map[*protoimpl.ExtensionInfo]string{ - E_Get: "GET", - E_Post: "POST", - E_Put: "PUT", - E_Patch: "PATCH", - E_Delete: "DELETE", - E_Options: "OPTIONS", - E_Head: "HEAD", - } -) +var HttpMethodOptions = map[*protoimpl.ExtensionInfo]string{ + E_Get: "GET", + E_Post: "POST", + E_Put: "PUT", + E_Patch: "PATCH", + E_Delete: "DELETE", + E_Options: "OPTIONS", + E_Head: "HEAD", +} func GetAllOptions(extensions map[*protoimpl.ExtensionInfo]string, opts ...protoreflect.ProtoMessage) map[string]interface{} { out := map[string]interface{}{} diff --git a/protoc-gen-http-swagger/protobuf/openapi/annotations.pb.go b/protoc-gen-http-swagger/protobuf/openapi/annotations.pb.go index fdc17b2..08d86aa 100644 --- a/protoc-gen-http-swagger/protobuf/openapi/annotations.pb.go +++ b/protoc-gen-http-swagger/protobuf/openapi/annotations.pb.go @@ -21,10 +21,11 @@ package openapi import ( + reflect "reflect" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" - reflect "reflect" ) const ( diff --git a/protoc-gen-http-swagger/protobuf/openapi/document.go b/protoc-gen-http-swagger/protobuf/openapi/document.go index ab3c703..b1779c2 100644 --- a/protoc-gen-http-swagger/protobuf/openapi/document.go +++ b/protoc-gen-http-swagger/protobuf/openapi/document.go @@ -339,11 +339,11 @@ func (m *Encoding) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("style")) info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Style)) } - if m.Explode != false { + if m.Explode { info.Content = append(info.Content, compiler.NewScalarNodeForString("explode")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Explode)) } - if m.AllowReserved != false { + if m.AllowReserved { info.Content = append(info.Content, compiler.NewScalarNodeForString("allowReserved")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowReserved)) } @@ -481,15 +481,15 @@ func (m *Header) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } - if m.Required != false { + if m.Required { info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } - if m.Deprecated != false { + if m.Deprecated { info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) } - if m.AllowEmptyValue != false { + if m.AllowEmptyValue { info.Content = append(info.Content, compiler.NewScalarNodeForString("allowEmptyValue")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowEmptyValue)) } @@ -497,11 +497,11 @@ func (m *Header) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("style")) info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Style)) } - if m.Explode != false { + if m.Explode { info.Content = append(info.Content, compiler.NewScalarNodeForString("explode")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Explode)) } - if m.AllowReserved != false { + if m.AllowReserved { info.Content = append(info.Content, compiler.NewScalarNodeForString("allowReserved")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowReserved)) } @@ -1111,7 +1111,7 @@ func (m *Operation) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("callbacks")) info.Content = append(info.Content, m.Callbacks.ToRawInfo()) } - if m.Deprecated != false { + if m.Deprecated { info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) } @@ -1156,15 +1156,15 @@ func (m *Parameter) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } - if m.Required != false { + if m.Required { info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } - if m.Deprecated != false { + if m.Deprecated { info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) } - if m.AllowEmptyValue != false { + if m.AllowEmptyValue { info.Content = append(info.Content, compiler.NewScalarNodeForString("allowEmptyValue")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowEmptyValue)) } @@ -1172,11 +1172,11 @@ func (m *Parameter) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("style")) info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Style)) } - if m.Explode != false { + if m.Explode { info.Content = append(info.Content, compiler.NewScalarNodeForString("explode")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Explode)) } - if m.AllowReserved != false { + if m.AllowReserved { info.Content = append(info.Content, compiler.NewScalarNodeForString("allowReserved")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowReserved)) } @@ -1396,7 +1396,7 @@ func (m *RequestBody) ToRawInfo() *yaml.Node { // always include this required field. info.Content = append(info.Content, compiler.NewScalarNodeForString("content")) info.Content = append(info.Content, m.Content.ToRawInfo()) - if m.Required != false { + if m.Required { info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } @@ -1519,7 +1519,7 @@ func (m *Schema) ToRawInfo() *yaml.Node { if m == nil { return info } - if m.Nullable != false { + if m.Nullable { info.Content = append(info.Content, compiler.NewScalarNodeForString("nullable")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Nullable)) } @@ -1527,11 +1527,11 @@ func (m *Schema) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("discriminator")) info.Content = append(info.Content, m.Discriminator.ToRawInfo()) } - if m.ReadOnly != false { + if m.ReadOnly { info.Content = append(info.Content, compiler.NewScalarNodeForString("readOnly")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ReadOnly)) } - if m.WriteOnly != false { + if m.WriteOnly { info.Content = append(info.Content, compiler.NewScalarNodeForString("writeOnly")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.WriteOnly)) } @@ -1547,7 +1547,7 @@ func (m *Schema) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) info.Content = append(info.Content, m.Example.ToRawInfo()) } - if m.Deprecated != false { + if m.Deprecated { info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) } @@ -1563,7 +1563,7 @@ func (m *Schema) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) } - if m.ExclusiveMaximum != false { + if m.ExclusiveMaximum { info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) } @@ -1571,7 +1571,7 @@ func (m *Schema) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) } - if m.ExclusiveMinimum != false { + if m.ExclusiveMinimum { info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) } @@ -1595,7 +1595,7 @@ func (m *Schema) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) } - if m.UniqueItems != false { + if m.UniqueItems { info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) } @@ -1961,11 +1961,11 @@ func (m *Xml) ToRawInfo() *yaml.Node { info.Content = append(info.Content, compiler.NewScalarNodeForString("prefix")) info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Prefix)) } - if m.Attribute != false { + if m.Attribute { info.Content = append(info.Content, compiler.NewScalarNodeForString("attribute")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Attribute)) } - if m.Wrapped != false { + if m.Wrapped { info.Content = append(info.Content, compiler.NewScalarNodeForString("wrapped")) info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Wrapped)) } diff --git a/protoc-gen-http-swagger/protobuf/openapi/openapi.pb.go b/protoc-gen-http-swagger/protobuf/openapi/openapi.pb.go index 1b31dac..5ef7057 100644 --- a/protoc-gen-http-swagger/protobuf/openapi/openapi.pb.go +++ b/protoc-gen-http-swagger/protobuf/openapi/openapi.pb.go @@ -23,10 +23,11 @@ package openapi import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const (