swagger-dsl 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +20 -0
- data/.gitignore +12 -0
- data/.prettierrc +3 -0
- data/.rspec +4 -0
- data/.rubocop.yml +13 -0
- data/.rubocop_airbnb.yml +2 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +92 -0
- data/Rakefile +9 -0
- data/bin/console +11 -0
- data/bin/fmt +9 -0
- data/bin/setup +8 -0
- data/lib/swagger/dsl.rb +29 -0
- data/lib/swagger/dsl/components.rb +25 -0
- data/lib/swagger/dsl/config.rb +14 -0
- data/lib/swagger/dsl/json_schema.rb +14 -0
- data/lib/swagger/dsl/json_schema/jimmy.rb +16 -0
- data/lib/swagger/dsl/json_schema/jimmy_patch.rb +19 -0
- data/lib/swagger/dsl/json_schema/subset_dsl.rb +15 -0
- data/lib/swagger/dsl/operation.rb +46 -0
- data/lib/swagger/dsl/parameter.rb +31 -0
- data/lib/swagger/dsl/parameters.rb +18 -0
- data/lib/swagger/dsl/parameters_in_type.rb +21 -0
- data/lib/swagger/dsl/rails_controller.rb +33 -0
- data/lib/swagger/dsl/resolve_module.rb +34 -0
- data/lib/swagger/dsl/serializer.rb +16 -0
- data/lib/swagger/dsl/version.rb +5 -0
- data/swagger-dsl.gemspec +45 -0
- metadata +286 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5cc961ef3920695d4d5ceb821614d851813f17d1260f770159114eccab257fb7
|
4
|
+
data.tar.gz: 0bc99296d8a9855b7be3d3e2a6df2600b0ec923cbde9ce07d21a55bcaccac43d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2100a4b87f0274ec94a99bff02f358dac6248e6069afa3539a3925cdad8fdce40f3cc8f32d56a22c3323172ad8cfbfa87500e4b0a6cd7969172d9ebd47bcae49
|
7
|
+
data.tar.gz: a4f54a4143025e57de805e945c1166de0bdd8b137ec1c1482c6be566f9fce550c0eeea2917791b6a411bc2f4ab20de5743116ff3f4e86affa03552074ee72604
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v1
|
12
|
+
- name: Set up Ruby 2.x
|
13
|
+
uses: actions/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.x
|
16
|
+
- name: Build and test with Rake
|
17
|
+
run: |
|
18
|
+
gem install bundler
|
19
|
+
bundle install --jobs 4 --retry 3
|
20
|
+
bundle exec rake
|
data/.gitignore
ADDED
data/.prettierrc
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
inherit_from:
|
2
|
+
- .rubocop_airbnb.yml
|
3
|
+
inherit_gem:
|
4
|
+
rubocop-config-prettier: config/rubocop.yml
|
5
|
+
# prettier
|
6
|
+
Style/PercentLiteralDelimiters:
|
7
|
+
Enabled: false
|
8
|
+
Airbnb/OptArgParameters:
|
9
|
+
Enabled: false
|
10
|
+
Airbnb/SimpleModifierConditional:
|
11
|
+
Enabled: false
|
12
|
+
RSpec/EmptyExampleGroup:
|
13
|
+
Enabled: false
|
data/.rubocop_airbnb.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2019 Narazaka
|
2
|
+
|
3
|
+
This software is provided 'as-is', without any express or implied
|
4
|
+
warranty. In no event will the authors be held liable for any damages
|
5
|
+
arising from the use of this software.
|
6
|
+
|
7
|
+
Permission is granted to anyone to use this software for any purpose,
|
8
|
+
including commercial applications, and to alter it and redistribute it
|
9
|
+
freely, subject to the following restrictions:
|
10
|
+
|
11
|
+
1. The origin of this software must not be misrepresented; you must not
|
12
|
+
claim that you wrote the original software. If you use this software
|
13
|
+
in a product, an acknowledgment in the product documentation would be
|
14
|
+
appreciated but is not required.
|
15
|
+
|
16
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
17
|
+
misrepresented as being the original software.
|
18
|
+
|
19
|
+
3. This notice may not be removed or altered from any source
|
20
|
+
distribution.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Swagger::DSL
|
2
|
+
|
3
|
+
Swagger (OpenAPI 3) DSL
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'swagger-dsl'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install swagger-dsl
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
class BaseSerializer
|
25
|
+
extend Swagger::DSL::Serializer
|
26
|
+
end
|
27
|
+
|
28
|
+
class UserSerializer < BaseSerializer
|
29
|
+
swagger do
|
30
|
+
id :integer
|
31
|
+
name :string
|
32
|
+
age :integer, minimum: 18
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class ApplicationController
|
37
|
+
extend Swagger::DSL::RailsController
|
38
|
+
end
|
39
|
+
|
40
|
+
class UsersController < ApplicationController
|
41
|
+
swagger :update do
|
42
|
+
params do
|
43
|
+
path :id, schema: :integer, required: true
|
44
|
+
query do
|
45
|
+
safe schema: :boolean
|
46
|
+
redirect do
|
47
|
+
required true
|
48
|
+
schema do
|
49
|
+
string!
|
50
|
+
format! "url"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
body do
|
57
|
+
# name :string
|
58
|
+
# age :integer, minimum: 18
|
59
|
+
cref! UserSerializer # "#/components/User"
|
60
|
+
end
|
61
|
+
|
62
|
+
render 200, dsl: :jimmy do # another json schema dsl by "jimmy" gem
|
63
|
+
object do
|
64
|
+
string :status, enum: %w[ok], default: :ok
|
65
|
+
cref :user, UserSerializer
|
66
|
+
require all
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def update
|
72
|
+
# some
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
Swagger::DSL.current["info"] = {
|
77
|
+
"title" => "my app",
|
78
|
+
"version" => "0.1.0",
|
79
|
+
}
|
80
|
+
|
81
|
+
JSON.dump(Swagger::DSL.current.as_json(except: "config"))
|
82
|
+
```
|
83
|
+
|
84
|
+
## Development
|
85
|
+
|
86
|
+
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.
|
87
|
+
|
88
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, 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).
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Narazaka/swagger-dsl.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "swagger/dsl"
|
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
|
data/bin/fmt
ADDED
data/bin/setup
ADDED
data/lib/swagger/dsl.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "./dsl/config"
|
2
|
+
require_relative "./dsl/version"
|
3
|
+
require_relative "./dsl/rails_controller"
|
4
|
+
require_relative "./dsl/serializer"
|
5
|
+
require_relative "./dsl/components"
|
6
|
+
require_relative "./dsl/resolve_module"
|
7
|
+
|
8
|
+
module Swagger
|
9
|
+
class DSL < Hash
|
10
|
+
include ResolveModule
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def current
|
14
|
+
@current ||= new
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :config
|
19
|
+
|
20
|
+
def initialize(schema = nil, config: Config.new)
|
21
|
+
merge!(schema || {})
|
22
|
+
self["openapi"] ||= "3.0.0"
|
23
|
+
self["info"] ||= {}
|
24
|
+
self["paths"] ||= {}
|
25
|
+
self["components"] = Components[self["components"] || {}]
|
26
|
+
@config = config
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative "./json_schema"
|
2
|
+
require_relative "./parameters"
|
3
|
+
require_relative "../dsl"
|
4
|
+
|
5
|
+
module Swagger
|
6
|
+
class DSL
|
7
|
+
class Components < Hash
|
8
|
+
STRING = "".freeze
|
9
|
+
|
10
|
+
def [](name)
|
11
|
+
# for autoload
|
12
|
+
if !Swagger::DSL.current.config.eager && STRING.respond_to?(:classify) && STRING.respond_to?(:safe_constantize)
|
13
|
+
serializer_name(name).classify.safe_constantize
|
14
|
+
end
|
15
|
+
super(name)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def serializer_name(name)
|
21
|
+
name.to_s.sub(/(?:Serializer)?$/, "Serializer")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Swagger
|
2
|
+
class DSL
|
3
|
+
class Config
|
4
|
+
attr_accessor :inject_key, :default_dsl, :dsl_options, :eager
|
5
|
+
|
6
|
+
def initialize(inject_key: "title", default_dsl: nil, dsl_options: nil, eager: false)
|
7
|
+
@inject_key = inject_key
|
8
|
+
@default_dsl = default_dsl
|
9
|
+
@dsl_options ||= { reference_name: ->(name) { name.sub(/Serializer$/, "") } }
|
10
|
+
@eager = eager
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "./json_schema/subset_dsl"
|
2
|
+
require_relative "./json_schema/jimmy"
|
3
|
+
require_relative "../dsl"
|
4
|
+
|
5
|
+
module Swagger
|
6
|
+
class DSL
|
7
|
+
class JsonSchema
|
8
|
+
def self.by(dsl_type = nil)
|
9
|
+
dsl_type ||= Swagger::DSL.current.config.default_dsl
|
10
|
+
dsl_type == :jimmy ? Jimmy : SubsetDSL
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "jimmy"
|
2
|
+
require_relative "./jimmy_patch"
|
3
|
+
|
4
|
+
module Swagger
|
5
|
+
class DSL
|
6
|
+
class JsonSchema
|
7
|
+
class Jimmy
|
8
|
+
DOMAIN = ::Jimmy::Domain.new("")
|
9
|
+
|
10
|
+
def self.dsl(&block)
|
11
|
+
DOMAIN.instance_eval(&block).schema.compile
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative "../../dsl"
|
2
|
+
|
3
|
+
# rubocop:disable Airbnb/ClassOrModuleDeclaredInWrongFile, Airbnb/ModuleMethodInWrongFile
|
4
|
+
module Jimmy
|
5
|
+
class SchemaCreation
|
6
|
+
module Referencing
|
7
|
+
def component(id)
|
8
|
+
name = "#/components/#{id}"
|
9
|
+
reference_name = Swagger::DSL.current.config.dsl_options[:reference_name]
|
10
|
+
reference_name ? reference_name.call(name) : name
|
11
|
+
end
|
12
|
+
|
13
|
+
def cref(*args, uri, &block)
|
14
|
+
ref(*args, component(uri), &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# rubocop:enable Airbnb/ClassOrModuleDeclaredInWrongFile, Airbnb/ModuleMethodInWrongFile
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "json/schema/subset/dsl"
|
2
|
+
require_relative "../../dsl"
|
3
|
+
|
4
|
+
module Swagger
|
5
|
+
class DSL
|
6
|
+
class JsonSchema
|
7
|
+
class SubsetDSL
|
8
|
+
def self.dsl(&block)
|
9
|
+
options = Swagger::DSL.current.config.dsl_options
|
10
|
+
Json::Schema::Subset::DSL.new(options: options, &block).compile!
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative "./json_schema"
|
2
|
+
require_relative "./parameters"
|
3
|
+
|
4
|
+
module Swagger
|
5
|
+
class DSL
|
6
|
+
class Operation < Hash
|
7
|
+
FORMAT_TYPE = {
|
8
|
+
json: "application/json", xml: "application/xml", plain: "text/plain", html: "text/html", csv: "text/csv"
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def initialize(operation_id, format: :json, &block)
|
12
|
+
self["operationId"] = operation_id
|
13
|
+
self["requestBody"] = { "content" => {}, "required" => true }
|
14
|
+
self["responses"] = {}
|
15
|
+
self["parameters"] = []
|
16
|
+
@format = format
|
17
|
+
instance_eval(&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def params(&block)
|
21
|
+
self["parameters"] = Parameters.new(&block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def body(format: @format, dsl: nil, &block)
|
25
|
+
self["requestBody"]["content"][FORMAT_TYPE[format]] = {
|
26
|
+
"schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block)
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def body_description(body_description = nil)
|
31
|
+
self["requestBody"]["description"] = body_description
|
32
|
+
end
|
33
|
+
|
34
|
+
def body_optional(optional = true)
|
35
|
+
self["requestBody"]["required"] = optional
|
36
|
+
end
|
37
|
+
|
38
|
+
def render(code = 200, format: @format, dsl: nil, &block)
|
39
|
+
self["responses"][code] ||= { "content" => {} }
|
40
|
+
self["responses"][code]["content"][FORMAT_TYPE[format]] = {
|
41
|
+
"schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block)
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative "./json_schema"
|
2
|
+
|
3
|
+
module Swagger
|
4
|
+
class DSL
|
5
|
+
class Parameter < Hash
|
6
|
+
def initialize(*args, &block)
|
7
|
+
unless args.empty?
|
8
|
+
self["name"] = args.first
|
9
|
+
args[1..-1].each { |arg| merge!(arg.map { |k, v| [k.to_s, v] }.to_h) }
|
10
|
+
canonical_schema!
|
11
|
+
end
|
12
|
+
instance_eval(&block) if block_given?
|
13
|
+
end
|
14
|
+
|
15
|
+
def schema(types = nil, dsl: nil, &block)
|
16
|
+
self["schema"] = types ? types : Swagger::DSL::JsonSchema.by(dsl).dsl(&block)
|
17
|
+
canonical_schema!
|
18
|
+
end
|
19
|
+
|
20
|
+
%w[description required deprecated allowEmptyValue style explode allowReserved example examples].each do |name|
|
21
|
+
define_method(name) { |value| self[name] = value }
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def canonical_schema!
|
27
|
+
self["schema"] = { "type" => self["schema"] } if !self["schema"].nil? && !self["schema"].is_a?(Hash)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "./parameters_in_type"
|
2
|
+
|
3
|
+
module Swagger
|
4
|
+
class DSL
|
5
|
+
class Parameters < Array
|
6
|
+
def initialize(format: :json, &block)
|
7
|
+
@format = format
|
8
|
+
instance_eval(&block)
|
9
|
+
end
|
10
|
+
|
11
|
+
%i[path query header cookie].each do |in_type|
|
12
|
+
define_method(in_type) do |*args, &block|
|
13
|
+
args.empty? ? ParametersInType.new(self, in_type, &block) : self << Parameter.new(*args, in: in_type, &block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "./parameter"
|
2
|
+
|
3
|
+
module Swagger
|
4
|
+
class DSL < Hash
|
5
|
+
class ParametersInType
|
6
|
+
def initialize(parent, type, &block)
|
7
|
+
@parent = parent
|
8
|
+
@type = type
|
9
|
+
instance_eval(&block)
|
10
|
+
end
|
11
|
+
|
12
|
+
def respond_to_missing?(name, include_private)
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_missing(name, *args, &block)
|
17
|
+
@parent << Parameter.new(name, *args, in: @type, &block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative "../dsl"
|
2
|
+
require_relative "./operation"
|
3
|
+
|
4
|
+
module Swagger
|
5
|
+
class DSL
|
6
|
+
module RailsController
|
7
|
+
class NotMatch < StandardError; end
|
8
|
+
class NotExactMatch < StandardError; end
|
9
|
+
|
10
|
+
def swagger(action, format = :json, path: nil, method: nil, &block)
|
11
|
+
operation_id = "#{name}##{action}"
|
12
|
+
|
13
|
+
defaults = { action: action.to_s, controller: name.underscore.sub(/_controller$/, "") }
|
14
|
+
route = Rails.application.routes.routes.routes.find { |r| r.required_defaults == defaults }
|
15
|
+
unless route
|
16
|
+
raise NotMatch,
|
17
|
+
"route not found! specify additional :path and :method key like { path: '/foos/{id}', method: 'get'}"
|
18
|
+
end
|
19
|
+
method ||= route.verb.downcase
|
20
|
+
if method.include?("|")
|
21
|
+
raise NotExactMatch, "route matched but verb can be #{verb}! specify :method key like 'get'."
|
22
|
+
end
|
23
|
+
path ||= route.path.spec.to_s.sub("(.:format)", "").gsub(/:(\w+)/, "{\\1}")
|
24
|
+
|
25
|
+
operation = Swagger::DSL::Operation.new(operation_id, format: format, &block)
|
26
|
+
Swagger::DSL.current["paths"][path] ||= {}
|
27
|
+
Swagger::DSL.current["paths"][path][method] = operation
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method :oas3, :swagger
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "json_refs"
|
2
|
+
require "hana"
|
3
|
+
require "active_support/core_ext/object/deep_dup"
|
4
|
+
|
5
|
+
module Swagger
|
6
|
+
class DSL
|
7
|
+
module ResolveModule
|
8
|
+
def resolved
|
9
|
+
JsonRefs.call(self.deep_dup)
|
10
|
+
end
|
11
|
+
|
12
|
+
def resolver
|
13
|
+
method(:resolve)
|
14
|
+
end
|
15
|
+
|
16
|
+
def resolve(part_schema)
|
17
|
+
walk(resolved, part_schema)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def walk(all, part)
|
23
|
+
if part.is_a?(Array)
|
24
|
+
part.map { |item| walk(all, item) }
|
25
|
+
elsif part.is_a?(Hash)
|
26
|
+
ref = part["$ref"] || part[:"$ref"]
|
27
|
+
ref ? walk(all, Hana::Pointer.new(ref[1..-1]).eval(all)) : part.map { |k, v| [k, walk(all, v)] }.to_h
|
28
|
+
else
|
29
|
+
part
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative "../dsl"
|
2
|
+
require_relative "./json_schema"
|
3
|
+
|
4
|
+
module Swagger
|
5
|
+
class DSL
|
6
|
+
module Serializer
|
7
|
+
def swagger(dsl: nil, &block)
|
8
|
+
name = self.name.sub(/Serializer$/, "")
|
9
|
+
Swagger::DSL.current["components"][name] =
|
10
|
+
Swagger::DSL::JsonSchema.by(dsl).dsl(&block).merge(Swagger::DSL.current.config.inject_key => name)
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :oas3, :swagger
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/swagger-dsl.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "swagger/dsl/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "swagger-dsl"
|
7
|
+
spec.version = Swagger::DSL::VERSION
|
8
|
+
spec.authors = %w[Narazaka]
|
9
|
+
spec.email = %w[info@narazaka.net]
|
10
|
+
spec.licenses = %w[Zlib]
|
11
|
+
|
12
|
+
spec.summary = "Swagger (OpenAPI 3) DSL"
|
13
|
+
spec.homepage = "https://github.com/Narazaka/swagger-dsl"
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/Narazaka/swagger-dsl.git"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/Narazaka/swagger-dsl/blob/master/CHANGELOG.md"
|
18
|
+
spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/#{spec.name}/#{spec.version}"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files =
|
23
|
+
Dir.chdir(File.expand_path("..", __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = %w[lib]
|
29
|
+
|
30
|
+
spec.add_dependency "jimmy", "~> 0.5"
|
31
|
+
spec.add_dependency "json-schema-subset-dsl", "~> 1.2"
|
32
|
+
spec.add_dependency "hana", "~> 1.3"
|
33
|
+
spec.add_dependency "json_refs", "~> 0.1"
|
34
|
+
spec.add_dependency "activesupport", "~> 6.0"
|
35
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.5"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.9"
|
38
|
+
spec.add_development_dependency "rspec-power_assert", "~> 1.1"
|
39
|
+
spec.add_development_dependency "rubocop", "~> 0.76"
|
40
|
+
spec.add_development_dependency "rubocop-airbnb", "~> 3"
|
41
|
+
spec.add_development_dependency "prettier", ">= 0.16"
|
42
|
+
spec.add_development_dependency "rubocop-config-prettier", "~> 0.1"
|
43
|
+
spec.add_development_dependency "yard", "~> 0.9"
|
44
|
+
spec.add_development_dependency "pry-byebug", "~> 3.7"
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,286 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: swagger-dsl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Narazaka
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jimmy
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json-schema-subset-dsl
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hana
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json_refs
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '6.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '6.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.5'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.5'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.9'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.9'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-power_assert
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.1'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.1'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.76'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.76'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-airbnb
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '3'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: prettier
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.16'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.16'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rubocop-config-prettier
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0.1'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0.1'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: yard
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0.9'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0.9'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: pry-byebug
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '3.7'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '3.7'
|
223
|
+
description:
|
224
|
+
email:
|
225
|
+
- info@narazaka.net
|
226
|
+
executables: []
|
227
|
+
extensions: []
|
228
|
+
extra_rdoc_files: []
|
229
|
+
files:
|
230
|
+
- ".github/workflows/ruby.yml"
|
231
|
+
- ".gitignore"
|
232
|
+
- ".prettierrc"
|
233
|
+
- ".rspec"
|
234
|
+
- ".rubocop.yml"
|
235
|
+
- ".rubocop_airbnb.yml"
|
236
|
+
- Gemfile
|
237
|
+
- LICENSE
|
238
|
+
- README.md
|
239
|
+
- Rakefile
|
240
|
+
- bin/console
|
241
|
+
- bin/fmt
|
242
|
+
- bin/setup
|
243
|
+
- lib/swagger/dsl.rb
|
244
|
+
- lib/swagger/dsl/components.rb
|
245
|
+
- lib/swagger/dsl/config.rb
|
246
|
+
- lib/swagger/dsl/json_schema.rb
|
247
|
+
- lib/swagger/dsl/json_schema/jimmy.rb
|
248
|
+
- lib/swagger/dsl/json_schema/jimmy_patch.rb
|
249
|
+
- lib/swagger/dsl/json_schema/subset_dsl.rb
|
250
|
+
- lib/swagger/dsl/operation.rb
|
251
|
+
- lib/swagger/dsl/parameter.rb
|
252
|
+
- lib/swagger/dsl/parameters.rb
|
253
|
+
- lib/swagger/dsl/parameters_in_type.rb
|
254
|
+
- lib/swagger/dsl/rails_controller.rb
|
255
|
+
- lib/swagger/dsl/resolve_module.rb
|
256
|
+
- lib/swagger/dsl/serializer.rb
|
257
|
+
- lib/swagger/dsl/version.rb
|
258
|
+
- swagger-dsl.gemspec
|
259
|
+
homepage: https://github.com/Narazaka/swagger-dsl
|
260
|
+
licenses:
|
261
|
+
- Zlib
|
262
|
+
metadata:
|
263
|
+
homepage_uri: https://github.com/Narazaka/swagger-dsl
|
264
|
+
source_code_uri: https://github.com/Narazaka/swagger-dsl.git
|
265
|
+
changelog_uri: https://github.com/Narazaka/swagger-dsl/blob/master/CHANGELOG.md
|
266
|
+
documentation_uri: https://www.rubydoc.info/gems/swagger-dsl/1.0.0
|
267
|
+
post_install_message:
|
268
|
+
rdoc_options: []
|
269
|
+
require_paths:
|
270
|
+
- lib
|
271
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
272
|
+
requirements:
|
273
|
+
- - ">="
|
274
|
+
- !ruby/object:Gem::Version
|
275
|
+
version: '0'
|
276
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
277
|
+
requirements:
|
278
|
+
- - ">="
|
279
|
+
- !ruby/object:Gem::Version
|
280
|
+
version: '0'
|
281
|
+
requirements: []
|
282
|
+
rubygems_version: 3.0.3
|
283
|
+
signing_key:
|
284
|
+
specification_version: 4
|
285
|
+
summary: Swagger (OpenAPI 3) DSL
|
286
|
+
test_files: []
|