Skip to content

Commit

Permalink
fix: enums will also be fully qualified with fully-qualified-message-…
Browse files Browse the repository at this point in the history
…names; add filter for services on tags
  • Loading branch information
sudorandom committed Jan 25, 2025
1 parent b66d9f2 commit 1f8726c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func appendToSpec(opts options.Options, spec *v3.Document, fd protoreflect.FileD
if err := addPathItemsFromFile(opts, fd, spec.Paths); err != nil {
return err
}
spec.Tags = append(spec.Tags, fileToTags(fd)...)
spec.Tags = append(spec.Tags, fileToTags(opts, fd)...)
return nil
}

Expand Down
7 changes: 6 additions & 1 deletion internal/converter/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,13 @@ func enumToSchema(state *State, tt protoreflect.EnumDescriptor) (string, *base.S
children = append(children, utils.CreateIntNode(strconv.FormatInt(int64(value.Number()), 10)))
}
}

title := string(tt.Name())
if state.Opts.FullyQualifiedMessageNames {
title = string(tt.FullName())
}
s := &base.Schema{
Title: string(tt.Name()),
Title: title,
Description: util.FormatComments(tt.ParentFile().SourceLocations().ByDescriptor(tt)),
Type: []string{"string"},
Enum: children,
Expand Down
6 changes: 5 additions & 1 deletion internal/converter/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import (
highbase "github.com/pb33f/libopenapi/datamodel/high/base"
"google.golang.org/protobuf/reflect/protoreflect"

"github.com/sudorandom/protoc-gen-connect-openapi/internal/converter/options"
"github.com/sudorandom/protoc-gen-connect-openapi/internal/converter/util"
)

func fileToTags(fd protoreflect.FileDescriptor) []*base.Tag {
func fileToTags(opts options.Options, fd protoreflect.FileDescriptor) []*base.Tag {
tags := []*highbase.Tag{}
services := fd.Services()
for i := 0; i < services.Len(); i++ {
service := services.Get(i)
if !opts.HasService(service.FullName()) {
continue
}
loc := fd.SourceLocations().ByDescriptor(service)
description := util.FormatComments(loc)

Expand Down

0 comments on commit 1f8726c

Please sign in to comment.