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 +4 -4
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/Rakefile +2 -0
- data/exe/krakend-openapi-importer +2 -1
- data/lib/importer/version.rb +1 -1
- data/lib/transformers/oa3_transformer.rb +10 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b495dbdfe6e95a0c77d87aaec6435a994e4634b7cd3ec69b64e5dce6087522b
|
4
|
+
data.tar.gz: b3e43422585c8b5c64728a878de8ef76c99d4ca00d4a95b73a759a0023b96539
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa4d241b604e619bc815ce779fa46f8e8e76d24e8fc98c35744d1a3f38f945bc703a4fe1934752d6d660dc2f89576cc356f3315eefc586dd2833647f72f12432
|
7
|
+
data.tar.gz: fff2da0a664b8db13b3929161d9bd47aa252e67b40975558e34b91966630adb85f3ddb4e2ad9629d4e6ee4a969c0250756f7a5b492f5dc36be817f788d1a7ee6
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.8
|
data/Gemfile.lock
CHANGED
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
|
-
|
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 `
|
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
data/lib/importer/version.rb
CHANGED
@@ -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,
|
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,
|
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
|
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.
|
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-
|
11
|
+
date: 2025-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|