krakend-openapi-importer 1.1.0 → 1.1.1

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: 42f8decc7a78765c173ba1fcbc56921b83e4b80f9e64528e2038b3a5582c57c1
4
- data.tar.gz: 8cc805c646fd57bb4b4ff509c93d15ff1ef11fc44efdf2ba7b17c4187a47aeb4
3
+ metadata.gz: 2b495dbdfe6e95a0c77d87aaec6435a994e4634b7cd3ec69b64e5dce6087522b
4
+ data.tar.gz: b3e43422585c8b5c64728a878de8ef76c99d4ca00d4a95b73a759a0023b96539
5
5
  SHA512:
6
- metadata.gz: 87882d563ba41ef98c9e8d989ee6386b1e4060a80c08a2fe208cec5c0c178734340f13148fad37613b5961e8be42f600c317a373fd8b07c37e91e0bbe2cade8e
7
- data.tar.gz: cb38f67effdc5439ad893d3a39f2d0544307e1e487dd9f9fbae22b97906c0326dd27ec7be7521951c645b77c293af530ee041838af5035e55817f44037431322
6
+ metadata.gz: fa4d241b604e619bc815ce779fa46f8e8e76d24e8fc98c35744d1a3f38f945bc703a4fe1934752d6d660dc2f89576cc356f3315eefc586dd2833647f72f12432
7
+ data.tar.gz: fff2da0a664b8db13b3929161d9bd47aa252e67b40975558e34b91966630adb85f3ddb4e2ad9629d4e6ee4a969c0250756f7a5b492f5dc36be817f788d1a7ee6
data/.rubocop.yml CHANGED
@@ -20,4 +20,7 @@ Metrics/MethodLength:
20
20
  Enabled: false
21
21
 
22
22
  Metrics/BlockLength:
23
+ Enabled: false
24
+
25
+ Style/HashSlice:
23
26
  Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.6
1
+ 2.7.8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- krakend-openapi-importer (1.1.0)
4
+ krakend-openapi-importer (1.1.1)
5
5
  thor (~> 1.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -35,7 +35,7 @@ Example config
35
35
  format: "json" # can be 'json' or 'yaml', optional, defaults to 'json'
36
36
  pretty: false # make JSON pretty, optional, defaults to false
37
37
  output: "output.json" # output file name, optional, defaults to 'output.json'
38
- all_roles: ["guest"] # fall back roles for auth validator plugin when operation 'x-jwt-roles` are not specified, optional
38
+ default_roles: ["guest"] # fall back roles for auth validator plugin when operation 'x-jwt-roles` are not specified, optional
39
39
  defaults:
40
40
  base:
41
41
  name: Example application
@@ -59,7 +59,7 @@ defaults:
59
59
 
60
60
  ### Auth Validator plugin configuration
61
61
 
62
- * You can specify custom roles for each OpenAPI [operation](https://swagger.io/specification/v3/#operation-object) using the `x-jwt-roles` [operation extension](https://swagger.io/specification/v3/#specification-extensions). If no `x-jwt-roles` are provided for an operation, the plugin will fall back to the default roles defined in the `all_roles` configuration.
62
+ * You can specify custom roles for each OpenAPI [operation](https://swagger.io/specification/v3/#operation-object) using the `x-jwt-roles` [operation extension](https://swagger.io/specification/v3/#specification-extensions). If no `x-jwt-roles` are provided for an operation, the plugin will fall back to the default roles defined in the `default_roles` configuration.
63
63
  * Importer supports `openIdConnect` and `oauth2` security schemes defined using [Security Requirement Objects](https://swagger.io/specification/v3/#security-requirement-object).
64
64
 
65
65
  ## Development
data/Rakefile CHANGED
@@ -14,4 +14,6 @@ Rake::TestTask.new(:test) do |t|
14
14
  t.test_files = FileList['test/**/*_test.rb']
15
15
  end
16
16
 
17
+ task spec: :test
18
+
17
19
  task default: :test
@@ -13,6 +13,7 @@ end
13
13
  begin
14
14
  KrakendOpenAPI::Importer.start(ARGV)
15
15
  rescue StandardError => e
16
- puts "ERROR: #{e.message}"
16
+ warn "ERROR: #{e.message}"
17
+ warn e.backtrace&.join("\n")
17
18
  exit 1
18
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KrakendOpenAPI
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
  end
@@ -6,6 +6,7 @@ module KrakendOpenAPI
6
6
  # Transforms OpenAPI paths to KrakenD endpoints
7
7
  class OA3ToKrakendTransformer
8
8
  SCHEME_TYPES_WITH_ROLES = %w[openIdConnect oauth2].freeze
9
+ PATH_METHODS = %w[get put post delete options head patch trace].freeze
9
10
 
10
11
  def initialize(spec, importer_config)
11
12
  @spec = spec
@@ -13,7 +14,7 @@ module KrakendOpenAPI
13
14
  end
14
15
 
15
16
  def transform_paths
16
- @spec.paths.map { |path, methods| transform_path(path, methods) }.flatten
17
+ @spec.paths.map { |path, path_items| transform_path(path, path_items) }.flatten
17
18
  end
18
19
 
19
20
  private
@@ -38,12 +39,18 @@ module KrakendOpenAPI
38
39
  end
39
40
  end
40
41
 
41
- def transform_path(path, methods)
42
+ def transform_path(path, path_items)
43
+ methods = path_items.filter { |k, _| PATH_METHODS.include?(k) }
42
44
  methods.map { |method, operation| transform_method(path, method, operation) }
43
45
  end
44
46
 
45
47
  def transform_method(path, method, operation)
46
- roles = operation['x-jwt-roles']&.length ? operation['x-jwt-roles'] : @importer_config['all_roles']
48
+ roles = if operation['x-jwt-roles']&.length
49
+ operation['x-jwt-roles']
50
+ else
51
+ # TODO: @deprecated 'all_roles' legacy config should be removed in the next major release
52
+ @importer_config['default_roles'] || @importer_config['all_roles']
53
+ end
47
54
  scopes = oauth_scopes_for(operation['security']) || oauth_scopes_for(@spec.security)
48
55
  plugins = []
49
56
  plugins << auth_validator_plugin(roles, scopes) if auth_validator_plugin_enabled?(roles, scopes)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: krakend-openapi-importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Semenenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-10 00:00:00.000000000 Z
11
+ date: 2025-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor