gitlab-grape-openapi 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5548e70ecc3368b56d965a6bbbc6ae8d448a8a230f0ff453c05d91fc3dfc4714
4
- data.tar.gz: f535c2530fa0eed45b85b92805973d62dc294b3c7475fd6464229dea5113f1b2
3
+ metadata.gz: afbabc9163e59aafb950577da68e96bd817c5c4357e2eae88aabe4b75baaaf1f
4
+ data.tar.gz: 74a9b9a8abb13c4a122bf59169dd7aaa147162f68b781b47d729c52bd8440f50
5
5
  SHA512:
6
- metadata.gz: 8410aab600a941dca435dd2da070dc1c68141cc5fea001452081216fd3b8f0714a1a87d39811ae9b482c55fc2350953c5bbe6979189631ad96a9d8641b7f42e8
7
- data.tar.gz: d1ed6e54fc2819e34b8b2acfdd2ef9077647f5c11b4b3bf7de59dad8466a480f4240edb8e30b22fb1a6e8c747e088ed8d2632f3e92e92aa75555f69f7760895a
6
+ metadata.gz: c9af1518142acff74821ed05d46605c9f6e33b8f08ccc33d438324196467dc573d6661b48d5b9b247d362b8b864ce0909755d8952d3e1b302b077bfa03aa6b7f
7
+ data.tar.gz: 03161ba25486070010a7ec67f2955a42f5d82e46c0eb78dbb4065f5df49870b69d9927a78afa40b513c04e9075806005eb558354cf59f4db10946928001a6cb1
data/README.md CHANGED
@@ -103,6 +103,7 @@ end
103
103
  | `excluded_api_classes` | `Array<String>` | `[]` | API class names to exclude from generation |
104
104
  | `tag_overrides` | `Hash` | `{}` | Map of tag names to their display overrides |
105
105
  | `annotations` | `Hash` | `{}` | Map of Grape route settings to OpenAPI extension names |
106
+ | `warnings` | `Boolean` | `false` | Emit stderr warnings for synthesized (undeclared) path params |
106
107
 
107
108
  ### Annotations
108
109
 
@@ -212,6 +213,111 @@ bundle exec rspec
212
213
  bundle exec rubocop
213
214
  ```
214
215
 
216
+ ### Releasing
217
+
218
+ Releases are driven by the
219
+ [gem-release CI component](https://gitlab.com/gitlab-org/components/gem-release)
220
+ and a merge request whose title contains `RELEASE`.
221
+
222
+ 1. Open a merge request from the
223
+ [Release template](.gitlab/merge_request_templates/Release.md). The
224
+ `/title RELEASE: v<NEW_VERSION>` quick action ensures the title
225
+ contains `RELEASE`, which is what exposes the release-creation and
226
+ `gem-publication` jobs.
227
+ 2. Bump the `VERSION` constant in
228
+ `lib/gitlab/grape_openapi/version.rb` and fill in the changelog per
229
+ the template.
230
+ 3. Get the MR reviewed and merged. **Do not run the `gem-publication`
231
+ job from the MR pipeline** — it is meant to stay un-run during
232
+ review (see below).
233
+ 4. After merge, follow the post-release steps in `CLAUDE.md` to bump
234
+ the `gitlab-grape-openapi` version in `gitlab-org/gitlab` and
235
+ regenerate the committed `openapi_v3.yaml`.
236
+
237
+ #### How publishing works
238
+
239
+ `GEM_HOST_API_KEY` is configured as an **inherited, protected**
240
+ variable on a parent group, so it is only exposed to pipelines running
241
+ on protected branches or protected tags. This is why running the
242
+ `gem-publication` job manually from the MR pipeline fails — the API key
243
+ is not available there.
244
+
245
+ The expected flow relies on the default branch being protected:
246
+
247
+ - During review, the MR-pipeline `gem-publication` job stays un-run
248
+ (it is `manual`, and would fail anyway without the key).
249
+ - When the version bump lands on the default branch (`main`), the
250
+ `gem-publication` job runs again — this time with the protected
251
+ `GEM_HOST_API_KEY` available — and publishes the gem to RubyGems.
252
+
253
+ The gem-release component's rules that re-trigger publication after
254
+ merge:
255
+
256
+ ```yaml
257
+ .gem-release-default-rules:
258
+ rules:
259
+ - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
260
+ changes: ["lib/**/version.rb"]
261
+ - if: '$CI_MERGE_REQUEST_TITLE =~ /RELEASE/ && "...dry_run..." == "true"'
262
+ - if: '$CI_MERGE_REQUEST_TITLE =~ /RELEASE/'
263
+ when: manual
264
+ ```
265
+
266
+ The first rule is the one that publishes: a `push` to the default
267
+ branch that changes `lib/**/version.rb`.
268
+
269
+ #### Verifying changes against `gitlab-org/gitlab`
270
+
271
+ Because the monorepo consumes this gem from RubyGems, a change can pass
272
+ this gem's own specs locally yet still break `gitlab-org/gitlab` CI once
273
+ the published gem is pulled in. Verify both locally and in CI before
274
+ releasing.
275
+
276
+ **Locally**, point the monorepo's `Gemfile` at your working copy of this
277
+ gem with a `path:` override:
278
+
279
+ ```ruby
280
+ gem 'gitlab-grape-openapi', path: '<absolute path to this repo>', feature_category: :api
281
+ ```
282
+
283
+ Run `bundle install` in the monorepo, then exercise the affected paths
284
+ (for example regenerate the spec with `bin/rake gitlab:openapi:v3:generate`
285
+ and run the relevant specs). When finished, revert with
286
+ `git restore Gemfile Gemfile.lock` so the override does not leak into a
287
+ commit.
288
+
289
+ **In CI**, a `path:` override only sees your local checkout, so open a
290
+ throwaway merge request in `gitlab-org/gitlab` that pins the `Gemfile` to
291
+ the exact commit you want to test and let its pipeline run. Replace the
292
+ dependency line:
293
+
294
+ ```ruby
295
+ gem 'gitlab-grape-openapi', '~> <CURRENT_VERSION>', feature_category: :api
296
+ ```
297
+
298
+ with a Git source:
299
+
300
+ ```ruby
301
+ gem 'gitlab-grape-openapi',
302
+ git: 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-grape-openapi.git',
303
+ ref: '<commit SHA>',
304
+ feature_category: :api
305
+ ```
306
+
307
+ Pinning with `ref:` (rather than `branch:`) freezes the exact commit so
308
+ CI does not drift if the branch moves. `Gemfile.next` is a symlink to
309
+ `Gemfile`, so this single edit covers both. Run `bundle install` to
310
+ regenerate `Gemfile.lock` with a GIT source block, commit it (do not
311
+ hand-edit it), and push. To faithfully reproduce the real migration's CI
312
+ conditions, also remove the in-tree gem under `gems/gitlab-grape-openapi/`
313
+ and its `.gitlab/ci/gitlab-gems.gitlab-ci.yml` and `.gitlab/CODEOWNERS`
314
+ entries, so Bundler cannot fall back to the vendored copy.
315
+
316
+ This throwaway branch is verification-only — do not merge it. Once the
317
+ gem is published, the real version bump uses a `'~> <NEW_VERSION>'`
318
+ constraint instead of the Git source (see the post-release steps in
319
+ `CLAUDE.md`).
320
+
215
321
  ## Contributing
216
322
 
217
323
  This gem is maintained by GitLab's API Platform team for internal use.
@@ -4,7 +4,7 @@ module Gitlab
4
4
  module GrapeOpenapi
5
5
  class Configuration
6
6
  attr_accessor :api_version, :api_prefix, :excluded_api_classes, :servers, :security_schemes, :info,
7
- :tag_overrides, :annotations, :coercer_mappings
7
+ :tag_overrides, :annotations, :coercer_mappings, :warnings
8
8
 
9
9
  def initialize
10
10
  @api_prefix = "api"
@@ -18,6 +18,7 @@ module Gitlab
18
18
  @tag_overrides = {}
19
19
  @annotations = {}
20
20
  @coercer_mappings = {}
21
+ @warnings = false
21
22
  end
22
23
  end
23
24
  end
@@ -116,14 +116,19 @@ module Gitlab
116
116
  params
117
117
  end
118
118
 
119
- # Emit a one-line stderr diagnostic identifying the route and API
119
+ # Emit a one-line stderr warning identifying the route and API
120
120
  # class responsible for a `schema: {}` entry in the generated spec.
121
+ # Disabled by default and gated behind `config.warnings` so it does
122
+ # not pollute stderr in callers that treat any warning output as a
123
+ # failure (e.g. GitLab's `fail_on_warnings` static-analysis wrapper).
121
124
  # The output is grep-friendly: each line starts with the literal
122
125
  # `[gitlab-grape-openapi]` tag and includes the HTTP method, the
123
126
  # full normalized path, the placeholder name, and the API class
124
127
  # name. From the class name, the source file follows GitLab's
125
128
  # autoload conventions (`API::Foo::Bar` -> `lib/api/foo/bar.rb`).
126
129
  def report_synthesized_parameter(placeholder)
130
+ return unless config.warnings
131
+
127
132
  api_class = route.app.options[:for] if route.app.respond_to?(:options)
128
133
  warn "[gitlab-grape-openapi] synthesized path param: " \
129
134
  "#{http_method} #{normalized_path} placeholder=:#{placeholder} " \
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module GrapeOpenapi
5
- # Version of the gem
6
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
7
6
  end
8
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-grape-openapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - group::api
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-03 00:00:00.000000000 Z
11
+ date: 2026-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: grape-entity
29
29
  requirement: !ruby/object:Gem::Requirement