Skip to content

Commit eaa0f94

Browse files
Add Support for vendor extensions processing and related functions
- Implemented comprehensive tests for vendor extensions in the transform package, covering various scenarios including disabled extensions, valid OpenAPI files with pagination, and provider matching. - Added utility functions for YAML parsing, template context building, and extension management. - Enhanced test coverage for operations, parameter extraction, and response validation. - Minor import adjustment in the TUI package to include the transform package.
1 parent 1d09e21 commit eaa0f94

17 files changed

Lines changed: 2533 additions & 105 deletions

.golangci.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ linters:
1010
- gocyclo
1111
- misspell
1212
- revive
13+
- gosec # Security checks
14+
- unused # Unused code detection
1315
disable:
1416
- asasalint
1517
- bodyclose
@@ -25,7 +27,6 @@ linters:
2527
- godox
2628
- goheader
2729
- goprintffuncname
28-
- gosec
2930
- lll
3031
- nakedret
3132
- nestif
@@ -40,7 +41,6 @@ linters:
4041
- tparallel
4142
- unconvert
4243
- unparam
43-
- unused
4444
- wastedassign
4545
- whitespace
4646
- wrapcheck
@@ -54,6 +54,11 @@ linters:
5454
min-complexity: 15
5555
misspell:
5656
locale: US
57+
gofmt:
58+
simplify: true
59+
gosec:
60+
confidence: medium
61+
severity: medium
5762
revive:
5863
confidence: 0.8
5964
severity: warning

.openapirc.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,70 @@
1+
# OpenMorph Default Configuration
2+
# This file demonstrates vendor extension configuration with auto-detection features
3+
4+
# Basic settings
15
input: ./openapi
26
backup: true
37
validate: true
8+
9+
# Key transformations
410
exclude:
511
- x-ignore
12+
- x-internal # Example of excluding internal extensions
613
mappings:
714
x-operation-group-name: x-fern-sdk-group-name
815
x-tag: x-fern-tag
16+
x-group: x-fern-sdk-group-name # Additional Fern mapping
17+
18+
# Pagination priority (optional - removes lower priority strategies)
19+
pagination_priority:
20+
- cursor
21+
- offset
22+
- page
23+
- checkpoint
24+
- none
25+
26+
# Vendor extension configuration
27+
vendor_extensions:
28+
enabled: true
29+
providers:
30+
fern:
31+
extension_name: "x-fern-pagination"
32+
target_level: "operation" # operation | path | global
33+
methods: ["get"] # HTTP methods to process
34+
field_mapping:
35+
request_params:
36+
# Auto-maps parameters to template variables
37+
cursor: ["cursor", "next_cursor", "after"]
38+
limit: ["limit", "size", "page_size", "per_page", "take"]
39+
offset: ["offset", "skip"]
40+
page: ["page", "page_number"]
41+
# Note: No results field mapping needed - auto-detected from response schemas!
42+
strategies:
43+
cursor:
44+
template:
45+
type: "cursor"
46+
cursor_param: "$request.{cursor_param}"
47+
page_size_param: "$request.{limit_param}"
48+
results_path: "$response.{results_field}"
49+
required_fields: ["cursor_param", "results_field"]
50+
offset:
51+
template:
52+
type: "offset"
53+
offset_param: "$request.{offset_param}"
54+
limit_param: "$request.{limit_param}"
55+
results_path: "$response.{results_field}"
56+
required_fields: ["offset_param", "results_field"]
57+
page:
58+
template:
59+
type: "page"
60+
page_param: "$request.{page_param}"
61+
page_size_param: "$request.{limit_param}"
62+
results_path: "$response.{results_field}"
63+
required_fields: ["page_param", "results_field"]
64+
checkpoint:
65+
template:
66+
type: "checkpoint"
67+
cursor_param: "$request.{cursor_param}"
68+
page_size_param: "$request.{limit_param}"
69+
results_path: "$response.{results_field}"
70+
required_fields: ["cursor_param", "results_field"]

Makefile

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ BINARY=openmorph
44
VERSION_FILE=.version
55
VERSION=$(shell cat $(VERSION_FILE) 2>/dev/null || echo "0.0.0")
66

7-
.PHONY: all build test lint release clean install version-show version-bump-patch version-bump-minor version-bump-major version-set version-tag version-release
7+
.PHONY: all build test lint format lint-fix lint-all release clean install version-show version-bump-patch version-bump-minor version-bump-major version-set version-tag version-release
88

99
all: build
1010

@@ -14,8 +14,32 @@ build:
1414
test:
1515
go test ./... -v
1616

17+
# Format code using gofmt and goimports
18+
format:
19+
@echo "🎨 Formatting Go code..."
20+
@gofmt -s -w .
21+
@if command -v goimports >/dev/null 2>&1; then \
22+
goimports -w -local github.com/developerkunal/OpenMorph .; \
23+
else \
24+
echo "⚠️ goimports not found. Install with: go install golang.org/x/tools/cmd/goimports@latest"; \
25+
fi
26+
@echo "✅ Code formatting completed"
27+
28+
# Run linters (reports issues)
1729
lint:
18-
golangci-lint run
30+
@echo "🔍 Running linters..."
31+
@golangci-lint run
32+
@echo "✅ Linting completed"
33+
34+
# Lint and auto-fix issues where possible
35+
lint-fix:
36+
@echo "🔧 Running linters with auto-fix..."
37+
@golangci-lint run --fix
38+
@echo "✅ Linting with auto-fix completed"
39+
40+
# Format code and run linters (complete code quality check)
41+
lint-all: format lint
42+
@echo "🎯 Complete code quality check completed"
1943

2044
release:
2145
goreleaser release --clean

0 commit comments

Comments
 (0)