Skip to content

Commit

Permalink
Merge pull request #1370 from max107/tags
Browse files Browse the repository at this point in the history
fix(expand): pass tags to merged openapi spec
  • Loading branch information
tdakkota authored Dec 18, 2024
2 parents cb52b1a + 15bee5c commit 295e0d2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions openapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Ref = jsonpointer.RefKey
// API represents parsed OpenAPI spec.
type API struct {
Version Version
Tags []Tag
Servers []Server
Operations []*Operation
Webhooks []Webhook
Expand Down
9 changes: 5 additions & 4 deletions openapi/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (

// Operation is an OpenAPI Operation.
type Operation struct {
OperationID string // optional
Summary string // optional
Description string // optional
Deprecated bool // optional
Tags []string // optional
OperationID string // optional
Summary string // optional
Description string // optional
Deprecated bool // optional

HTTPMethod string
Path Path
Expand Down
11 changes: 11 additions & 0 deletions openapi/parser/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ func (e *expander) Spec(api *openapi.API) (spec *ogen.Spec, err error) {
e.components = spec.Components

spec.OpenAPI = api.Version.String()

tags := make([]ogen.Tag, len(api.Tags))
for i, tag := range api.Tags {
tags[i] = ogen.Tag{
Name: tag.Name,
Description: tag.Description,
}
}
spec.Tags = tags

// FIXME(tdakkota): store actual information
spec.Info = ogen.Info{
Title: "Expanded spec",
Expand Down Expand Up @@ -263,6 +273,7 @@ func (e *expander) OAuthFlow(flow *openapi.OAuthFlow) (expanded *ogen.OAuthFlow,
func (e *expander) Operation(op *openapi.Operation) (expanded *ogen.Operation, err error) {
expanded = new(ogen.Operation)

expanded.Tags = op.Tags
expanded.OperationID = op.OperationID
expanded.Summary = op.Summary
expanded.Description = op.Description
Expand Down
1 change: 1 addition & 0 deletions openapi/parser/parse_path_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (p *parser) parseOp(
}()

op := &openapi.Operation{
Tags: spec.Tags,
OperationID: spec.OperationID,
Summary: spec.Summary,
Description: spec.Description,
Expand Down
7 changes: 7 additions & 0 deletions openapi/tag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package openapi

// Tag represents parsed OpenAPI tags.
type Tag struct {
Name string
Description string
}

0 comments on commit 295e0d2

Please sign in to comment.