apia-open_api 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/apia-open_api.gemspec +3 -3
- data/lib/apia/open_api/objects/response.rb +10 -4
- data/lib/apia/open_api/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce32b2c3d98cff03c533669e56c860dcda6b97a0deb554d423f8c208645ea87a
|
4
|
+
data.tar.gz: 9f9d5b952f2cc7141a0c207fa8d43c9d5d7a2a617dabb1819bb07e6a7decc691
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b83929f1bc986f6ce7d8d736f30b76992868bd6442d72b9f8456d83537bc91b1b8d4297ad94655aaf86720d40468305215f2e28fcd61f63253ee9d24fc59874
|
7
|
+
data.tar.gz: 13c108fcb4596a5912781732192e4bac034c6dd7a441e951edff6b740515e188a3ee03ba73cb63c518f235bff5a57b09a0dd3a8f3dcff77f79ccfb81edfbb61c
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Apia OpenAPI Specification
|
2
2
|
|
3
|
-
This gem can generate an [OpenAPI](https://www.openapis.org/) compatible schema from an API implemented using [Apia](https://github.com/
|
3
|
+
This gem can generate an [OpenAPI](https://www.openapis.org/) compatible schema from an API implemented using [Apia](https://github.com/apiaframework/apia).
|
4
4
|
|
5
5
|
This gem is in the early phases of development and breaking changes may be introduced whilst the gem is in the 0.1.x version range.
|
6
6
|
|
@@ -12,7 +12,7 @@ Install the gem and add to the application's Gemfile by executing:
|
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
-
The schema can be mounted in much the same way as an [Apia API](https://github.com/
|
15
|
+
The schema can be mounted in much the same way as an [Apia API](https://github.com/apiaframework/apia) itself.
|
16
16
|
|
17
17
|
For example, for a Ruby on Rails application:
|
18
18
|
|
@@ -85,7 +85,7 @@ You can also run `bin/console` for an interactive prompt that will allow you to
|
|
85
85
|
|
86
86
|
## Contributing
|
87
87
|
|
88
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
88
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/apiaframework/apia-open_api.
|
89
89
|
|
90
90
|
## License
|
91
91
|
|
data/apia-open_api.gemspec
CHANGED
@@ -8,13 +8,13 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Paul Sturgess"]
|
9
9
|
|
10
10
|
spec.summary = "Apia OpenAPI spec generator"
|
11
|
-
spec.homepage = "https://github.com/
|
11
|
+
spec.homepage = "https://github.com/apiaframework/apia-openapi"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = ">= 2.7.0"
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
-
spec.metadata["source_code_uri"] = "https://github.com/
|
17
|
-
spec.metadata["changelog_uri"] = "https://github.com/
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/apiaframework/apia-openapi"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/apiaframework/apia-openapi/changelog.md"
|
18
18
|
|
19
19
|
spec.metadata["rubygems_mfa_required"] = "false" # rubocop:disable Gemspec/RequireMFA (enabling MFA means we cannot auto publish via the CI)
|
20
20
|
|
@@ -36,6 +36,7 @@ module Apia
|
|
36
36
|
@route_spec = route_spec
|
37
37
|
@api_authenticator = api_authenticator
|
38
38
|
@http_status = @endpoint.definition.http_status
|
39
|
+
@response_type = @endpoint.definition.response_type
|
39
40
|
end
|
40
41
|
|
41
42
|
def add_to_spec
|
@@ -46,9 +47,14 @@ module Apia
|
|
46
47
|
private
|
47
48
|
|
48
49
|
def add_sucessful_response_schema
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
if @response_type == Apia::Response::PLAIN
|
51
|
+
content_schema = { type: "string" }
|
52
|
+
else
|
53
|
+
content_schema = {
|
54
|
+
properties: generate_properties_for_successful_response
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
52
58
|
required_fields = @endpoint.definition.fields.select { |_, field| field.condition.nil? }
|
53
59
|
content_schema[:required] = required_fields.keys if required_fields.any?
|
54
60
|
|
@@ -56,7 +62,7 @@ module Apia
|
|
56
62
|
"#{@http_status}": {
|
57
63
|
description: @endpoint.definition.description || "",
|
58
64
|
content: {
|
59
|
-
|
65
|
+
@response_type => {
|
60
66
|
schema: content_schema
|
61
67
|
}
|
62
68
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apia-open_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Sturgess
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -47,13 +47,13 @@ files:
|
|
47
47
|
- lib/apia/open_api/rack.rb
|
48
48
|
- lib/apia/open_api/specification.rb
|
49
49
|
- lib/apia/open_api/version.rb
|
50
|
-
homepage: https://github.com/
|
50
|
+
homepage: https://github.com/apiaframework/apia-openapi
|
51
51
|
licenses:
|
52
52
|
- MIT
|
53
53
|
metadata:
|
54
|
-
homepage_uri: https://github.com/
|
55
|
-
source_code_uri: https://github.com/
|
56
|
-
changelog_uri: https://github.com/
|
54
|
+
homepage_uri: https://github.com/apiaframework/apia-openapi
|
55
|
+
source_code_uri: https://github.com/apiaframework/apia-openapi
|
56
|
+
changelog_uri: https://github.com/apiaframework/apia-openapi/changelog.md
|
57
57
|
rubygems_mfa_required: 'false'
|
58
58
|
post_install_message:
|
59
59
|
rdoc_options: []
|