Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Code ownership for openapi
# See: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

* @zoobzio
26 changes: 26 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repository:
name: openapi
description: OpenAPI 3.1 as native Go types
homepage: https://github.com/zoobzio/openapi
has_wiki: true
has_downloads: true
default_branch: main
allow_squash_merge: true
allow_merge_commit: false
allow_rebase_merge: false
delete_branch_on_merge: true

branches:
- name: main
protection:
required_pull_request_reviews:
required_approving_review_count: 1
dismiss_stale_reviews: true
require_code_owner_reviews: true
required_status_checks:
strict: true
contexts:
- CI Complete
enforce_admins: true
required_linear_history: true
restrictions: null
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ jobs:
with:
name: benchmark-results
path: benchmark_results.txt

ci-complete:
name: CI Complete
runs-on: ubuntu-latest
if: always()
needs: [test, lint, benchmark]
steps:
- name: Check results
run: |
if [[ "${{ needs.test.result }}" != "success" || "${{ needs.lint.result }}" != "success" || "${{ needs.benchmark.result }}" != "success" ]]; then
echo "One or more CI jobs failed"
exit 1
fi
6 changes: 6 additions & 0 deletions docs/3.types.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ OpenAPI
│ └── SecurityRequirement
├── Tags[]
│ └── Tag
├── TagGroups[] (x-tagGroups)
│ └── TagGroup
└── ExternalDocumentation
```

Expand Down Expand Up @@ -205,6 +207,10 @@ Tag
├── Description
└── ExternalDocs

TagGroup (x-tagGroups vendor extension)
├── Name
└── Tags[]

ExternalDocumentation
├── URL
└── Description
Expand Down
7 changes: 7 additions & 0 deletions openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type OpenAPI struct {
Servers []Server `json:"servers,omitempty" yaml:"servers,omitempty"`
Security []SecurityRequirement `json:"security,omitempty" yaml:"security,omitempty"`
Tags []Tag `json:"tags,omitempty" yaml:"tags,omitempty"`
TagGroups []TagGroup `json:"x-tagGroups,omitempty" yaml:"x-tagGroups,omitempty"`
}

// Info provides metadata about the API.
Expand Down Expand Up @@ -187,6 +188,12 @@ type Tag struct {
Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

// TagGroup groups tags for documentation tools like Redoc.
type TagGroup struct {
Name string `json:"name" yaml:"name"`
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
}

// ExternalDocumentation allows referencing an external resource.
type ExternalDocumentation struct {
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Expand Down
17 changes: 17 additions & 0 deletions openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,23 @@ func TestTag(t *testing.T) {
}
}

func TestTagGroup(t *testing.T) {
group := TagGroup{
Name: "Account",
Tags: []string{"Authentication", "Users"},
}

if group.Name != "Account" {
t.Errorf("expected name 'Account', got %q", group.Name)
}
if len(group.Tags) != 2 {
t.Errorf("expected 2 tags, got %d", len(group.Tags))
}
if group.Tags[0] != "Authentication" {
t.Errorf("expected first tag 'Authentication', got %q", group.Tags[0])
}
}

func TestMediaType(t *testing.T) {
mediaType := MediaType{
Schema: &Schema{Type: NewSchemaType("object")},
Expand Down
Loading