rspec-openapi 0.21.2 → 0.21.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/create_release.yml +79 -0
- data/.github/workflows/publish.yml +46 -0
- data/.gitignore +1 -0
- data/README.md +4 -3
- data/lib/rspec/openapi/schema_builder.rb +17 -9
- data/lib/rspec/openapi/schema_merger.rb +6 -1
- data/lib/rspec/openapi/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 10130361a7c2ee93e28be624decd6662215eaeb981a28981f02e5f1c95e82559
|
|
4
|
+
data.tar.gz: f32bbbe9f13c4a2b454ba4138b7c4825ca582f2ad32af73318c0a9c0c3d81147
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad8029bb23d7c9ec5b2a6c6898d82b906a061806e93912b166e6ab6b5464263dc936a3bbe86e821eea01a3d60e49f379327a966d8d1986e99258997f9132823e
|
|
7
|
+
data.tar.gz: 310ab5b4ff9b5a63555881679e77f0e1e829d3e1b296df79170db0915441bb70f5c8ebc553444574c93de80e6a7f510c2f26622c9df1052848dfc789df87d1f6
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
name: prepare release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version:
|
|
7
|
+
description: 'Version to release (e.g. 0.21.3 or v0.21.3)'
|
|
8
|
+
required: true
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
push:
|
|
12
|
+
name: Prepare release PR
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
|
17
|
+
contents: write # required to push release branch and open PR
|
|
18
|
+
pull-requests: write # required to create the release PR with GITHUB_TOKEN
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v5
|
|
22
|
+
with:
|
|
23
|
+
fetch-depth: 0
|
|
24
|
+
|
|
25
|
+
- name: Bump version.rb
|
|
26
|
+
run: |
|
|
27
|
+
set -euo pipefail
|
|
28
|
+
version="${{ github.event.inputs.version }}"
|
|
29
|
+
version="${version#v}"
|
|
30
|
+
|
|
31
|
+
echo "VERSION_NO_V=$version" >> "$GITHUB_ENV"
|
|
32
|
+
echo "VERSION_TAG=v$version" >> "$GITHUB_ENV"
|
|
33
|
+
|
|
34
|
+
current_version=$(ruby -e "require_relative './lib/rspec/openapi/version'; puts RSpec::OpenAPI::VERSION")
|
|
35
|
+
VERSION_NO_V="$version" CURRENT_VERSION="$current_version" ruby - <<'RUBY'
|
|
36
|
+
version = ENV.fetch('VERSION_NO_V')
|
|
37
|
+
unless version.match?(/\A\d+(?:\.\d+)*\z/)
|
|
38
|
+
warn "Invalid version format: #{version}"
|
|
39
|
+
exit 1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
require 'rubygems'
|
|
43
|
+
new_version = Gem::Version.new(version)
|
|
44
|
+
current_version = Gem::Version.new(ENV.fetch('CURRENT_VERSION'))
|
|
45
|
+
if new_version <= current_version
|
|
46
|
+
warn "Given version (#{new_version}) must be newer than current version (#{current_version})"
|
|
47
|
+
exit 1
|
|
48
|
+
end
|
|
49
|
+
RUBY
|
|
50
|
+
|
|
51
|
+
ruby -pi -e "sub(/VERSION = .*/, \"VERSION = '$version'\")" lib/rspec/openapi/version.rb
|
|
52
|
+
git status --short
|
|
53
|
+
|
|
54
|
+
- name: Commit version bump
|
|
55
|
+
run: |
|
|
56
|
+
set -euo pipefail
|
|
57
|
+
version="$VERSION_NO_V"
|
|
58
|
+
|
|
59
|
+
release_branch="release/v${version}"
|
|
60
|
+
echo "RELEASE_BRANCH=${release_branch}" >> "$GITHUB_ENV"
|
|
61
|
+
|
|
62
|
+
git config user.name "github-actions[bot]"
|
|
63
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
64
|
+
git commit -am "Bump version to ${version}"
|
|
65
|
+
git push origin "HEAD:${release_branch}"
|
|
66
|
+
|
|
67
|
+
- name: Open release PR
|
|
68
|
+
uses: peter-evans/create-pull-request@v6
|
|
69
|
+
with:
|
|
70
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
71
|
+
add-paths: |
|
|
72
|
+
lib/rspec/openapi/version.rb
|
|
73
|
+
branch: ${{ env.RELEASE_BRANCH }}
|
|
74
|
+
title: Release v${{ env.VERSION_NO_V }}
|
|
75
|
+
commit-message: Bump version to ${{ env.VERSION_NO_V }}
|
|
76
|
+
body: |
|
|
77
|
+
Automated release PR created by workflow_dispatch.
|
|
78
|
+
- Version: v${{ env.VERSION_NO_V }}
|
|
79
|
+
- Triggered by: ${{ github.actor }}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Publish to RubyGems
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
name: Publish gem and GitHub release
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write # for RubyGems trusted publishing
|
|
15
|
+
contents: write # to create GitHub release
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v5
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
|
|
22
|
+
- name: Set up Ruby
|
|
23
|
+
uses: ruby/setup-ruby@v1
|
|
24
|
+
with:
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
ruby-version: ruby
|
|
27
|
+
|
|
28
|
+
- name: Verify tag matches version.rb
|
|
29
|
+
run: |
|
|
30
|
+
set -euo pipefail
|
|
31
|
+
tag="${GITHUB_REF_NAME}"
|
|
32
|
+
version="${tag#v}"
|
|
33
|
+
file_version=$(ruby -e "require_relative './lib/rspec/openapi/version'; puts RSpec::OpenAPI::VERSION")
|
|
34
|
+
if [ "$version" != "$file_version" ]; then
|
|
35
|
+
echo "Tag version ($version) does not match lib/rspec/openapi/version.rb ($file_version)" >&2
|
|
36
|
+
exit 1
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
- uses: rubygems/release-gem@v1
|
|
40
|
+
|
|
41
|
+
- name: Create GitHub release
|
|
42
|
+
uses: softprops/action-gh-release@v2
|
|
43
|
+
with:
|
|
44
|
+
tag_name: ${{ github.ref_name }}
|
|
45
|
+
name: ${{ github.ref_name }}
|
|
46
|
+
generate_release_notes: true
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -410,9 +410,10 @@ Existing RSpec plugins which have OpenAPI integration:
|
|
|
410
410
|
|
|
411
411
|
## Releasing
|
|
412
412
|
|
|
413
|
-
1.
|
|
414
|
-
2.
|
|
415
|
-
3.
|
|
413
|
+
1. Ensure RubyGems trusted publishing is configured for this repo and gem ownership (see [Trusted publishing](https://guides.rubygems.org/trusted-publishing/)).
|
|
414
|
+
2. In GitHub Actions, run the `prepare release` workflow manually. It bumps `lib/rspec/openapi/version.rb`, pushes `release/v<version>` to origin, and opens a PR.
|
|
415
|
+
3. Review and merge the release PR into the default branch.
|
|
416
|
+
4. Create and push a tag `v<version>` on the merged commit (via the GitHub UI or `git tag v<version>; git push origin v<version>`). Tag creation triggers the `Publish to RubyGems` workflow, which publishes the gem and creates the GitHub release notes automatically.
|
|
416
417
|
|
|
417
418
|
## License
|
|
418
419
|
|
|
@@ -272,15 +272,21 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
|
272
272
|
else
|
|
273
273
|
unique_types = property_variations.map { |p| p[:type] }.compact.uniq
|
|
274
274
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
merged_schema[:properties][key][:items] = build_merged_schema_from_variations(items_variations)
|
|
280
|
-
when 'object'
|
|
281
|
-
merged_schema[:properties][key] = build_merged_schema_from_variations(property_variations)
|
|
275
|
+
if unique_types.size > 1
|
|
276
|
+
# Different types detected - create oneOf
|
|
277
|
+
unique_props = property_variations.map { |p| p.reject { |k, _| k == :nullable } }.uniq
|
|
278
|
+
merged_schema[:properties][key] = { oneOf: unique_props }
|
|
282
279
|
else
|
|
283
|
-
|
|
280
|
+
case unique_types.first
|
|
281
|
+
when 'array'
|
|
282
|
+
merged_schema[:properties][key] = { type: 'array' }
|
|
283
|
+
items_variations = property_variations.map { |p| p[:items] }.compact
|
|
284
|
+
merged_schema[:properties][key][:items] = build_merged_schema_from_variations(items_variations)
|
|
285
|
+
when 'object'
|
|
286
|
+
merged_schema[:properties][key] = build_merged_schema_from_variations(property_variations)
|
|
287
|
+
else
|
|
288
|
+
merged_schema[:properties][key] = property_variations.first.dup
|
|
289
|
+
end
|
|
284
290
|
end
|
|
285
291
|
end
|
|
286
292
|
|
|
@@ -311,7 +317,9 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
|
311
317
|
|
|
312
318
|
has_nullable = all_prop_variations.any?(&:nil?) || nullable_only.any?
|
|
313
319
|
|
|
314
|
-
if prop_variations.
|
|
320
|
+
if prop_variations.empty? && has_nullable
|
|
321
|
+
merged[:properties][key] = { nullable: true }
|
|
322
|
+
elsif prop_variations.size == 1
|
|
315
323
|
merged[:properties][key] = prop_variations.first.dup
|
|
316
324
|
merged[:properties][key][:nullable] = true if has_nullable
|
|
317
325
|
elsif prop_variations.size > 1
|
|
@@ -25,7 +25,12 @@ class << RSpec::OpenAPI::SchemaMerger = Object.new
|
|
|
25
25
|
|
|
26
26
|
spec.each do |key, value|
|
|
27
27
|
if base[key].is_a?(Hash) && value.is_a?(Hash)
|
|
28
|
-
|
|
28
|
+
# If the new value has oneOf, replace the entire value instead of merging
|
|
29
|
+
if value.key?(:oneOf)
|
|
30
|
+
base[key] = value
|
|
31
|
+
else
|
|
32
|
+
merge_schema!(base[key], value) unless base[key].key?(:$ref)
|
|
33
|
+
end
|
|
29
34
|
elsif base[key].is_a?(Array) && value.is_a?(Array)
|
|
30
35
|
# parameters need to be merged as if `name` and `in` were the Hash keys.
|
|
31
36
|
merge_arrays(base, key, value)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-openapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.21.
|
|
4
|
+
version: 0.21.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Takashi Kokubun
|
|
@@ -63,6 +63,8 @@ files:
|
|
|
63
63
|
- ".github/dependabot.yml"
|
|
64
64
|
- ".github/release.yaml"
|
|
65
65
|
- ".github/workflows/codeql-analysis.yml"
|
|
66
|
+
- ".github/workflows/create_release.yml"
|
|
67
|
+
- ".github/workflows/publish.yml"
|
|
66
68
|
- ".github/workflows/rubocop.yml"
|
|
67
69
|
- ".github/workflows/test.yml"
|
|
68
70
|
- ".gitignore"
|
|
@@ -108,7 +110,7 @@ licenses:
|
|
|
108
110
|
metadata:
|
|
109
111
|
homepage_uri: https://github.com/exoego/rspec-openapi
|
|
110
112
|
source_code_uri: https://github.com/exoego/rspec-openapi
|
|
111
|
-
changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.21.
|
|
113
|
+
changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.21.4
|
|
112
114
|
rubygems_mfa_required: 'true'
|
|
113
115
|
rdoc_options: []
|
|
114
116
|
require_paths:
|