dry_open_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/Custom.md +10 -0
  3. data/.gitignore +12 -0
  4. data/.rubocop.yml +10 -0
  5. data/CHANGELOG.md +0 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +68 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +85 -0
  11. data/Rakefile +7 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/dry_open_api.gemspec +32 -0
  15. data/lib/dry_open_api.rb +49 -0
  16. data/lib/dry_open_api/callback.rb +23 -0
  17. data/lib/dry_open_api/components.rb +54 -0
  18. data/lib/dry_open_api/contact.rb +23 -0
  19. data/lib/dry_open_api/data_types.rb +31 -0
  20. data/lib/dry_open_api/discriminator.rb +40 -0
  21. data/lib/dry_open_api/encoding.rb +25 -0
  22. data/lib/dry_open_api/equatable_as_content.rb +13 -0
  23. data/lib/dry_open_api/example.rb +24 -0
  24. data/lib/dry_open_api/external_documentation.rb +20 -0
  25. data/lib/dry_open_api/header.rb +42 -0
  26. data/lib/dry_open_api/info.rb +38 -0
  27. data/lib/dry_open_api/license.rb +20 -0
  28. data/lib/dry_open_api/link.rb +50 -0
  29. data/lib/dry_open_api/media_type.rb +35 -0
  30. data/lib/dry_open_api/o_auth_flow.rb +25 -0
  31. data/lib/dry_open_api/o_auth_flows.rb +27 -0
  32. data/lib/dry_open_api/operation.rb +60 -0
  33. data/lib/dry_open_api/parameter.rb +66 -0
  34. data/lib/dry_open_api/path_item.rb +42 -0
  35. data/lib/dry_open_api/paths.rb +26 -0
  36. data/lib/dry_open_api/reference.rb +21 -0
  37. data/lib/dry_open_api/request_body.rb +22 -0
  38. data/lib/dry_open_api/response.rb +55 -0
  39. data/lib/dry_open_api/responses.rb +37 -0
  40. data/lib/dry_open_api/schema.rb +107 -0
  41. data/lib/dry_open_api/security_requirement.rb +20 -0
  42. data/lib/dry_open_api/security_schema.rb +35 -0
  43. data/lib/dry_open_api/serializers.rb +7 -0
  44. data/lib/dry_open_api/serializers/yaml_serializer.rb +17 -0
  45. data/lib/dry_open_api/server.rb +21 -0
  46. data/lib/dry_open_api/server_variable.rb +21 -0
  47. data/lib/dry_open_api/specification.rb +44 -0
  48. data/lib/dry_open_api/tag.rb +23 -0
  49. data/lib/dry_open_api/version.rb +3 -0
  50. data/lib/dry_open_api/xml.rb +26 -0
  51. metadata +211 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 410e041fe43bb48c3197f1d98e29254c4ed8d9f19f507db94b4a852f198f1702
4
+ data.tar.gz: 6d51949d99fafddf33b4898632f6ce7eb28fb35eff823e96017bd09b704150c7
5
+ SHA512:
6
+ metadata.gz: 2d066ca3f18976236fe0436f1058970f2d2a91153984fbda787ef5fa484395505a1a0957c67fe5be70bc8d48221994be3edf7233fc517dbf1f96926d900f4557
7
+ data.tar.gz: 9804d55aed8fda7e00eff30ffea814e72676e4dba002b1facb1fda454562edb9d13e711f58313ac3a8f25d824080515564aa0321569e9df88cc33cdb20f399dd
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: Why and What
3
+ about: Write reasons first, Then write specific content.
4
+
5
+ ---
6
+
7
+ ## Why
8
+
9
+
10
+ ## What
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .rubocop-https---raw-githubusercontent-com-talentplatforms-shared-rubocop-master--talentplatforms-rubocop-yml
@@ -0,0 +1,10 @@
1
+ # these files cascade and build the base config of our linting
2
+ inherit_from:
3
+ - https://raw.githubusercontent.com/talentplatforms/shared-rubocop/master/.talentplatforms-rubocop.yml
4
+ # - .rubocop_todo.yml
5
+
6
+ # service specifics start below
7
+
8
+ # if we need to turn of rules, shut up about it!
9
+ Lint/RedundantCopEnableDirective:
10
+ Enabled: false
File without changes
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ngtknt@me.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in open_api.gemspec
6
+ gemspec
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dry_open_api (0.1.0)
5
+ activesupport (~> 6.0)
6
+ dry-initializer (~> 3.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (6.0.2.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2)
17
+ bump (0.8.0)
18
+ coderay (1.1.2)
19
+ concurrent-ruby (1.1.5)
20
+ diff-lcs (1.3)
21
+ docile (1.3.2)
22
+ dry-initializer (3.0.3)
23
+ i18n (1.8.1)
24
+ concurrent-ruby (~> 1.0)
25
+ json (2.3.0)
26
+ method_source (0.9.2)
27
+ minitest (5.13.0)
28
+ pry (0.12.2)
29
+ coderay (~> 1.1.0)
30
+ method_source (~> 0.9.0)
31
+ rake (10.5.0)
32
+ rspec (3.9.0)
33
+ rspec-core (~> 3.9.0)
34
+ rspec-expectations (~> 3.9.0)
35
+ rspec-mocks (~> 3.9.0)
36
+ rspec-core (3.9.0)
37
+ rspec-support (~> 3.9.0)
38
+ rspec-expectations (3.9.0)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.9.0)
41
+ rspec-mocks (3.9.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-support (3.9.0)
45
+ simplecov (0.17.1)
46
+ docile (~> 1.1)
47
+ json (>= 1.8, < 3)
48
+ simplecov-html (~> 0.10.0)
49
+ simplecov-html (0.10.2)
50
+ thread_safe (0.3.6)
51
+ tzinfo (1.2.6)
52
+ thread_safe (~> 0.1)
53
+ zeitwerk (2.2.2)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ bump
60
+ bundler (~> 2.0.2)
61
+ dry_open_api!
62
+ pry
63
+ rake (~> 10.0)
64
+ rspec (~> 3.0)
65
+ simplecov
66
+
67
+ BUNDLED WITH
68
+ 2.0.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Kent Nagata
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,85 @@
1
+ `dry_open_api`
2
+
3
+ Providing a [dry](https://dry-rb.org/) version of th [open_api gem](https://github.com/ngtk/open_api).
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'dry_open_api'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install dry_open_api
19
+
20
+ ## Usage
21
+ It has two use case:
22
+
23
+ 1. Serializing from PORO to yaml
24
+ 2. Deserializing yaml to PORO
25
+
26
+ ### Serializing
27
+
28
+ ```rb
29
+ spec = DryOpenApi::Specification.new(
30
+ openapi: "3.0.1",
31
+ info: DryOpenApi::Info.new(
32
+ title: "Awesome API",
33
+ description: "It provides something awesome",
34
+ version: "1.0.0",
35
+ ),
36
+ paths: DryOpenApi::Paths.new(
37
+ "/pets": DryOpenApi::PathItem.new(
38
+ get: DryOpenApi::Operation.new(
39
+ description: "Returns all pets from the system that the user has access to",
40
+ responses: DryOpenApi::Responses.new(
41
+ "200": DryOpenApi::Response.new(
42
+ description: "A list of pets.",
43
+ content: {
44
+ "application/json": DryOpenApi::MediaType.new(
45
+ schema: DryOpenApi::Schema.new(
46
+ type: "array",
47
+ items: DryOpenApi::Reference.new(ref: "#/components/schemas/pet"),
48
+ )
49
+ )
50
+ }
51
+ )
52
+ )
53
+ )
54
+ )
55
+ )
56
+ )
57
+
58
+ yaml = DryOpenApi::Serializers::YamlSerializer.serialize(spec)
59
+ File.write("spec.yml", yaml)
60
+ ```
61
+
62
+ ### Deserializing
63
+
64
+ ```rb
65
+ yaml = File.read("spec.yml")
66
+ spec = DryOpenApi::Serializers::YamlSerializer.deserialize(yaml)
67
+ ```
68
+
69
+ ## Development
70
+
71
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
72
+
73
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, run `bundle exec rake bump:patch` to update the version, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
74
+
75
+ ## Contributing
76
+
77
+ Bug reports and pull requests are welcome on GitHub at https://github.com/talentplatforms/dry_open_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
78
+
79
+ ## License
80
+
81
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
82
+
83
+ ## Code of Conduct
84
+
85
+ Everyone interacting in the OpenApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/talentplatforms/dry_open_api/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "bump/tasks"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "open_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "dry_open_api/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "dry_open_api"
7
+ spec.version = DryOpenApi::VERSION
8
+ spec.authors = ["Andy Ruck"]
9
+ spec.email = ["devops@talentplatforms.net"]
10
+
11
+ spec.summary = "Dry-PORO OpenAPI 3.x"
12
+ spec.description = "It provides a dried PORO of OpenAPI specification."
13
+ spec.homepage = "https://github.com/talentplatforms/dry_open_api"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "activesupport", "~> 6.0"
24
+ spec.add_runtime_dependency "dry-initializer", "~> 3.0"
25
+
26
+ spec.add_development_dependency "bundler", "~> 2.0.2", ">= 2.0.2"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "simplecov"
31
+ spec.add_development_dependency "bump"
32
+ end
@@ -0,0 +1,49 @@
1
+ # Dependant libraries
2
+ require 'active_support'
3
+ require 'active_support/core_ext/hash'
4
+ require 'active_support/core_ext/string/inflections'
5
+ require 'active_support/core_ext/object/inclusion'
6
+
7
+ # dry_open_api/*
8
+ require 'dry_open_api/equatable_as_content'
9
+ require 'dry_open_api/version'
10
+ require 'dry_open_api/data_types'
11
+
12
+ # Models
13
+ require 'dry_open_api/specification'
14
+ require 'dry_open_api/info'
15
+ require 'dry_open_api/contact'
16
+ require 'dry_open_api/license'
17
+ require 'dry_open_api/server'
18
+ require 'dry_open_api/server_variable'
19
+ require 'dry_open_api/components'
20
+ require 'dry_open_api/paths'
21
+ require 'dry_open_api/path_item'
22
+ require 'dry_open_api/operation'
23
+ require 'dry_open_api/external_documentation'
24
+ require 'dry_open_api/parameter'
25
+ require 'dry_open_api/request_body'
26
+ require 'dry_open_api/media_type'
27
+ require 'dry_open_api/encoding'
28
+ require 'dry_open_api/responses'
29
+ require 'dry_open_api/response'
30
+ require 'dry_open_api/callback'
31
+ require 'dry_open_api/example'
32
+ require 'dry_open_api/link'
33
+ require 'dry_open_api/header'
34
+ require 'dry_open_api/tag'
35
+ require 'dry_open_api/reference'
36
+ require 'dry_open_api/schema'
37
+ require 'dry_open_api/discriminator'
38
+ require 'dry_open_api/xml'
39
+ require 'dry_open_api/security_schema'
40
+ require 'dry_open_api/o_auth_flows'
41
+ require 'dry_open_api/o_auth_flow'
42
+ require 'dry_open_api/security_requirement'
43
+
44
+ # Serializer
45
+ require 'dry_open_api/serializers'
46
+
47
+ # the base module ;)
48
+ module DryOpenApi
49
+ end
@@ -0,0 +1,23 @@
1
+ # open api spec
2
+ module DryOpenApi
3
+ # https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#callback-object
4
+ class Callback
5
+ extend Forwardable
6
+
7
+ def initialize(**hash)
8
+ self.hash = hash.with_indifferent_access
9
+ end
10
+
11
+ def_delegator :hash, :[]
12
+
13
+ def self.load(hash)
14
+ return unless hash
15
+
16
+ new(**hash.symbolize_keys)
17
+ end
18
+
19
+ private
20
+
21
+ attr_accessor :hash
22
+ end
23
+ end