graphiti-openapi 0.1.0
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 +7 -0
- data/.editorconfig +10 -0
- data/.gitignore +20 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +16 -0
- data/MIT-LICENSE +20 -0
- data/README.md +45 -0
- data/Rakefile +20 -0
- data/app/assets/packs/api.js +27 -0
- data/app/controllers/graphiti/open_api/application_controller.rb +7 -0
- data/app/controllers/graphiti/open_api/specifications_controller.rb +21 -0
- data/app/helpers/graphiti/open_api/application_helper.rb +6 -0
- data/app/models/graphiti/open_api/action.rb +130 -0
- data/app/models/graphiti/open_api/attribute.rb +40 -0
- data/app/models/graphiti/open_api/endpoint.rb +72 -0
- data/app/models/graphiti/open_api/functions.rb +16 -0
- data/app/models/graphiti/open_api/generator.rb +174 -0
- data/app/models/graphiti/open_api/parameters.rb +30 -0
- data/app/models/graphiti/open_api/relationship.rb +65 -0
- data/app/models/graphiti/open_api/resource.rb +322 -0
- data/app/models/graphiti/open_api/schema.rb +32 -0
- data/app/models/graphiti/open_api/source.rb +27 -0
- data/app/models/graphiti/open_api/struct.rb +12 -0
- data/app/models/graphiti/open_api/type.rb +38 -0
- data/app/models/graphiti/open_api/types.rb +10 -0
- data/app/views/graphiti/open_api/specifications/index.html.erb +6 -0
- data/app/views/graphiti/open_api/specifications/index.yaml.erb +1 -0
- data/app/views/layouts/graphiti/open_api/application.html.erb +12 -0
- data/bin/console +6 -0
- data/bin/rails +26 -0
- data/bin/setup +8 -0
- data/bin/webpack +20 -0
- data/config/openapi.yml +66 -0
- data/config/routes.rb +5 -0
- data/graphiti-openapi.gemspec +48 -0
- data/lib/graphiti-openapi.rb +1 -0
- data/lib/graphiti/open_api.rb +15 -0
- data/lib/graphiti/open_api/engine.rb +16 -0
- data/lib/graphiti/open_api/version.rb +5 -0
- data/lib/tasks/graphiti_openapi.rake +33 -0
- data/lib/templates/installer.rb +20 -0
- metadata +353 -0
| @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            require "graphiti/open_api"
         | 
| 2 | 
            +
            require_relative "struct"
         | 
| 3 | 
            +
            require_relative "resource"
         | 
| 4 | 
            +
            require_relative "endpoint"
         | 
| 5 | 
            +
            require_relative "type"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Graphiti::OpenAPI
         | 
| 8 | 
            +
              class Schema < Struct
         | 
| 9 | 
            +
                attribute :resources, Types.Array(ResourceData)
         | 
| 10 | 
            +
                attribute :endpoints, Types::Hash.map(Types::Coercible::String, EndpointData)
         | 
| 11 | 
            +
                attribute :types, Types::Hash.map(Types::Symbol, TypeData)
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                # @return [Resources{String => Resource}]
         | 
| 14 | 
            +
                def resources
         | 
| 15 | 
            +
                  Resources.load(self)
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                # @return [Endpoints{String => Endpoint}]
         | 
| 19 | 
            +
                def endpoints
         | 
| 20 | 
            +
                  Endpoints.load(self)
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                # @return [{Symbol => Type}]
         | 
| 24 | 
            +
                def types
         | 
| 25 | 
            +
                  __attributes__[:types].each_with_object({}) do |(id, type), result|
         | 
| 26 | 
            +
                    result[id] = Type.new(type.to_hash.merge(name: id))
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                memoize :resources, :endpoints, :types
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require "graphiti/open_api"
         | 
| 2 | 
            +
            require_relative "struct"
         | 
| 3 | 
            +
            require_relative "functions"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Graphiti::OpenAPI
         | 
| 6 | 
            +
              class Source < Struct
         | 
| 7 | 
            +
                DEFAULT_REWRITE = -> (text) { text }
         | 
| 8 | 
            +
                DEFAULT_PARSE = JSON.method(:parse)
         | 
| 9 | 
            +
                DEFAULT_PROCESS = Functions[:deep_symbolize_keys]
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                attribute :name, Types::Coercible::String
         | 
| 12 | 
            +
                attribute :path, Types::Pathname
         | 
| 13 | 
            +
                attribute :data, Types::Hash
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def self.load(path, name: path.basename, rewrite: DEFAULT_REWRITE, process: DEFAULT_PROCESS, parse: DEFAULT_PARSE)
         | 
| 16 | 
            +
                  text = rewrite.(path.read)
         | 
| 17 | 
            +
                  parsed = parse.(text)
         | 
| 18 | 
            +
                  data = process.(parsed)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  new(
         | 
| 21 | 
            +
                    name: name,
         | 
| 22 | 
            +
                    path: path,
         | 
| 23 | 
            +
                    data: data,
         | 
| 24 | 
            +
                  )
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            require "graphiti/open_api"
         | 
| 2 | 
            +
            require "forwardable"
         | 
| 3 | 
            +
            require "dry-struct"
         | 
| 4 | 
            +
            require "dry/core/memoizable"
         | 
| 5 | 
            +
            require_relative "types"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Graphiti::OpenAPI
         | 
| 8 | 
            +
              class Struct < Dry::Struct
         | 
| 9 | 
            +
                include Dry::Core::Memoizable
         | 
| 10 | 
            +
                extend Forwardable
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
            end
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            require "graphiti/open_api"
         | 
| 2 | 
            +
            require "graphiti/types"
         | 
| 3 | 
            +
            require_relative "struct"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Graphiti::OpenAPI
         | 
| 6 | 
            +
              class TypeData < Struct
         | 
| 7 | 
            +
                attribute :kind, Types::String
         | 
| 8 | 
            +
                attribute :description, Types::String
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              class Type < TypeData
         | 
| 12 | 
            +
                TYPES_MAP = Hash.new do |hash, type|
         | 
| 13 | 
            +
                  hash[type] = {type: type}
         | 
| 14 | 
            +
                end.merge(
         | 
| 15 | 
            +
                  hash: {type: :object, additionalProperties: true},
         | 
| 16 | 
            +
                  datetime: {type: :string, format: :'date-time'},
         | 
| 17 | 
            +
                  date: {type: :string, format: :date},
         | 
| 18 | 
            +
                  time: {type: :string, format: :'date-time'},
         | 
| 19 | 
            +
                  inet: {type: :string, format: :ipv4},
         | 
| 20 | 
            +
                )
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                attribute :name, Types::Symbol
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def dry_type
         | 
| 25 | 
            +
                  Graphiti::Types[name]
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                def canonical_name
         | 
| 29 | 
            +
                  Graphiti::Types.name_for(name)
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                def to_schema
         | 
| 33 | 
            +
                  TYPES_MAP[canonical_name].dup
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                memoize :dry_type, :canonical_name
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            <%= generator.to_openapi(format: :yaml) %>
         | 
    
        data/bin/console
    ADDED
    
    
    
        data/bin/rails
    ADDED
    
    | @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            # This command will automatically be run when you run "rails" with Rails gems
         | 
| 3 | 
            +
            # installed from the root of your application.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ENGINE_ROOT = File.expand_path('..', __dir__)
         | 
| 6 | 
            +
            ENGINE_PATH = File.expand_path('../lib/graphiti/open_api/engine', __dir__)
         | 
| 7 | 
            +
            APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # Set up gems listed in the Gemfile.
         | 
| 10 | 
            +
            ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
         | 
| 11 | 
            +
            require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require "rails"
         | 
| 14 | 
            +
            # Pick the frameworks you want:
         | 
| 15 | 
            +
            require "active_model/railtie"
         | 
| 16 | 
            +
            # require "active_job/railtie"
         | 
| 17 | 
            +
            require "active_record/railtie"
         | 
| 18 | 
            +
            # require "active_storage/engine"
         | 
| 19 | 
            +
            require "action_controller/railtie"
         | 
| 20 | 
            +
            # require "action_mailer/railtie"
         | 
| 21 | 
            +
            require "action_view/railtie"
         | 
| 22 | 
            +
            # require "action_cable/engine"
         | 
| 23 | 
            +
            # require "sprockets/railtie"
         | 
| 24 | 
            +
            require "webpacker"
         | 
| 25 | 
            +
            require "rails/test_unit/railtie"
         | 
| 26 | 
            +
            require 'rails/engine/commands'
         | 
    
        data/bin/setup
    ADDED
    
    
    
        data/bin/webpack
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
         | 
| 4 | 
            +
            ENV["NODE_ENV"] ||= "development"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            ENGINE_ROOT = File.expand_path('..', __dir__)
         | 
| 7 | 
            +
            ENGINE_PATH = File.expand_path('../lib/graphiti/open_api/engine', __dir__)
         | 
| 8 | 
            +
            APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            # Set up gems listed in the Gemfile.
         | 
| 11 | 
            +
            ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
         | 
| 12 | 
            +
            require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            require_relative '../spec/dummy/config/boot'
         | 
| 15 | 
            +
            Dir.chdir 'spec/dummy' do
         | 
| 16 | 
            +
              system "bin/rails yarn:install" unless File.file?("node_modules/.bin/webpack")
         | 
| 17 | 
            +
              require "webpacker"
         | 
| 18 | 
            +
              require "webpacker/webpack_runner"
         | 
| 19 | 
            +
              Webpacker::WebpackRunner.run(ARGV)
         | 
| 20 | 
            +
            end
         | 
    
        data/config/openapi.yml
    ADDED
    
    | @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            openapi: 3.0.1
         | 
| 2 | 
            +
            info:
         | 
| 3 | 
            +
              title: My API
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
              # description: API description
         | 
| 6 | 
            +
              # termsOfService: /tos
         | 
| 7 | 
            +
              contact:
         | 
| 8 | 
            +
                email: developer@example.test
         | 
| 9 | 
            +
                name: Developer Example
         | 
| 10 | 
            +
                # url: 'https://developer.example.test/'
         | 
| 11 | 
            +
            security:
         | 
| 12 | 
            +
              - bearerAuth: []
         | 
| 13 | 
            +
            components:
         | 
| 14 | 
            +
              securitySchemes:
         | 
| 15 | 
            +
                bearerAuth:
         | 
| 16 | 
            +
                  type: http
         | 
| 17 | 
            +
                  scheme: bearer
         | 
| 18 | 
            +
                  bearerFormat: JWT
         | 
| 19 | 
            +
              responses:
         | 
| 20 | 
            +
                '200':
         | 
| 21 | 
            +
                  description: OK
         | 
| 22 | 
            +
                  content:
         | 
| 23 | 
            +
                    application/vnd.api+json:
         | 
| 24 | 
            +
                      schema:
         | 
| 25 | 
            +
                        $ref: '#/components/schemas/jsonapi_info'
         | 
| 26 | 
            +
                '202':
         | 
| 27 | 
            +
                  description: Accepted
         | 
| 28 | 
            +
                '204':
         | 
| 29 | 
            +
                  description: No Content
         | 
| 30 | 
            +
                '400':
         | 
| 31 | 
            +
                  description: Bad Request
         | 
| 32 | 
            +
                  content:
         | 
| 33 | 
            +
                    application/vnd.api+json:
         | 
| 34 | 
            +
                      schema:
         | 
| 35 | 
            +
                        $ref: '#/components/schemas/jsonapi_failure'
         | 
| 36 | 
            +
                '401':
         | 
| 37 | 
            +
                  description: Unauthorized
         | 
| 38 | 
            +
                  content:
         | 
| 39 | 
            +
                    application/vnd.api+json:
         | 
| 40 | 
            +
                      schema:
         | 
| 41 | 
            +
                        $ref: '#/components/schemas/jsonapi_failure'
         | 
| 42 | 
            +
                '403':
         | 
| 43 | 
            +
                  description: Forbidden
         | 
| 44 | 
            +
                  content:
         | 
| 45 | 
            +
                    application/vnd.api+json:
         | 
| 46 | 
            +
                      schema:
         | 
| 47 | 
            +
                        $ref: '#/components/schemas/jsonapi_failure'
         | 
| 48 | 
            +
                '404':
         | 
| 49 | 
            +
                  description: Not Found
         | 
| 50 | 
            +
                  content:
         | 
| 51 | 
            +
                    application/vnd.api+json:
         | 
| 52 | 
            +
                      schema:
         | 
| 53 | 
            +
                        $ref: '#/components/schemas/jsonapi_failure'
         | 
| 54 | 
            +
                '409':
         | 
| 55 | 
            +
                  description: Conflict
         | 
| 56 | 
            +
                  content:
         | 
| 57 | 
            +
                    application/vnd.api+json:
         | 
| 58 | 
            +
                      schema:
         | 
| 59 | 
            +
                        $ref: '#/components/schemas/jsonapi_failure'
         | 
| 60 | 
            +
                '422':
         | 
| 61 | 
            +
                  description: Unprocessable Entity
         | 
| 62 | 
            +
                  content:
         | 
| 63 | 
            +
                    application/vnd.api+json:
         | 
| 64 | 
            +
                      schema:
         | 
| 65 | 
            +
                        $ref: '#/components/schemas/jsonapi_failure'
         | 
| 66 | 
            +
            paths:
         | 
    
        data/config/routes.rb
    ADDED
    
    
| @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            require_relative "lib/graphiti/open_api/version"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Gem::Specification.new do |spec|
         | 
| 4 | 
            +
              spec.name = "graphiti-openapi"
         | 
| 5 | 
            +
              spec.version = Graphiti::OpenAPI::VERSION
         | 
| 6 | 
            +
              spec.authors = ["Alex Semyonov"]
         | 
| 7 | 
            +
              spec.email = ["alex@semyonov.us"]
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              spec.summary = %q{OpenAPI 3.0 specification for your (Graphiti) JSON:API}
         | 
| 10 | 
            +
              spec.description = spec.summary
         | 
| 11 | 
            +
              spec.homepage = "https://github.com/alsemyonov/graphiti-openapi"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              if spec.respond_to?(:metadata)
         | 
| 14 | 
            +
                spec.metadata["homepage_uri"] = spec.homepage
         | 
| 15 | 
            +
                spec.metadata["source_code_uri"] = spec.homepage
         | 
| 16 | 
            +
                spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              # Specify which files should be added to the gem when it is released.
         | 
| 20 | 
            +
              # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         | 
| 21 | 
            +
              spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
         | 
| 22 | 
            +
                `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
              spec.bindir = "exe"
         | 
| 25 | 
            +
              spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 26 | 
            +
              spec.require_paths = ["lib"]
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              spec.add_runtime_dependency "railties", "~> 5.2.2"
         | 
| 29 | 
            +
              spec.add_runtime_dependency "activemodel"
         | 
| 30 | 
            +
              spec.add_runtime_dependency "responders"
         | 
| 31 | 
            +
              spec.add_runtime_dependency "kaminari"
         | 
| 32 | 
            +
              spec.add_runtime_dependency "graphiti", "~> 1.0.beta.8"
         | 
| 33 | 
            +
              spec.add_runtime_dependency "dry-struct", "~> 0.6.0"
         | 
| 34 | 
            +
              spec.add_runtime_dependency "transproc"
         | 
| 35 | 
            +
              spec.add_runtime_dependency "webpacker"
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              spec.add_development_dependency "bundler", "~> 2.0"
         | 
| 38 | 
            +
              spec.add_development_dependency "rake", "~> 10.0"
         | 
| 39 | 
            +
              spec.add_development_dependency "rspec", "~> 3.0"
         | 
| 40 | 
            +
              spec.add_development_dependency "rspec-rails", "~> 3.8"
         | 
| 41 | 
            +
              spec.add_development_dependency "rspec-its"
         | 
| 42 | 
            +
              spec.add_development_dependency "rufo"
         | 
| 43 | 
            +
              spec.add_development_dependency "pry"
         | 
| 44 | 
            +
              spec.add_development_dependency "activerecord"
         | 
| 45 | 
            +
              spec.add_development_dependency "pg"
         | 
| 46 | 
            +
              spec.add_development_dependency "graphiti_spec_helpers"
         | 
| 47 | 
            +
              spec.add_development_dependency "factory_bot_rails"
         | 
| 48 | 
            +
            end
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "graphiti/open_api"
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require "graphiti/open_api/version"
         | 
| 2 | 
            +
            require "active_support"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Graphiti
         | 
| 5 | 
            +
              module OpenAPI
         | 
| 6 | 
            +
                class Error < StandardError
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ActiveSupport::Inflector.inflections(:en) do |inflect|
         | 
| 12 | 
            +
              inflect.acronym "API"
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            require "graphiti/open_api/engine"
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            require "rails"
         | 
| 2 | 
            +
            require "responders"
         | 
| 3 | 
            +
            require "graphiti"
         | 
| 4 | 
            +
            require "webpacker"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Graphiti
         | 
| 7 | 
            +
              module OpenAPI
         | 
| 8 | 
            +
                class Engine < ::Rails::Engine
         | 
| 9 | 
            +
                  isolate_namespace Graphiti::OpenAPI
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  initializer "graphiti.openapi.init" do
         | 
| 12 | 
            +
                    Mime::Type.register "text/yaml", :yaml
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            jsonapi_schema = 'public/schemas/jsonapi.json'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            namespace :graphiti do
         | 
| 6 | 
            +
              namespace :openapi do
         | 
| 7 | 
            +
                desc "Copy over the assets pack"
         | 
| 8 | 
            +
                task install: %I[environment run_installer]
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                task :run_installer => jsonapi_schema do
         | 
| 11 | 
            +
                  installer_template = File.expand_path("../templates/installer.rb", __dir__)
         | 
| 12 | 
            +
                  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{installer_template}"
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                task generate: :environment do
         | 
| 16 | 
            +
                  generator = Graphiti::OpenAPI::Generator.new
         | 
| 17 | 
            +
                  api = Rails.root.join("public#{ApplicationResource.endpoint_namespace}")
         | 
| 18 | 
            +
                  api.join("openapi.json").write(generator.to_openapi.to_json)
         | 
| 19 | 
            +
                  api.join("openapi.yaml").write(generator.to_openapi(format: :yaml))
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            namespace :assets do
         | 
| 25 | 
            +
              task precompile: "graphiti:openapi:generate"
         | 
| 26 | 
            +
            end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            file jsonapi_schema do |t|
         | 
| 29 | 
            +
              require 'open-uri'
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              # mkdir_p(File.dirname(t.name))
         | 
| 32 | 
            +
              File.write(t.name, open('http://jsonapi.org/schema').read)
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            root = File.expand_path("../..", __dir__)
         | 
| 2 | 
            +
            packs = File.directory?("app/assets/packs") ? "app/assets/packs" : "app/javascripts/packs"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            say "Copying api.js to #{packs}/"
         | 
| 5 | 
            +
            copy_file "#{root}/app/assets/packs/api.js", "#{packs}/api.js"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            say "Copying openapi.yml to config/"
         | 
| 8 | 
            +
            copy_file "#{root}/config/openapi.yml", "config/openapi.yml"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            say "Ignoring openapi specifications"
         | 
| 11 | 
            +
            File.write ".gitignore", "" unless File.file?(".gitignore")
         | 
| 12 | 
            +
            append_to_file ".gitignore" do
         | 
| 13 | 
            +
              <<~IGNORE
         | 
| 14 | 
            +
                public/api/v1/openapi.json
         | 
| 15 | 
            +
                public/api/v1/openapi.yaml
         | 
| 16 | 
            +
              IGNORE
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            say "Installing JavaScript dependencies"
         | 
| 20 | 
            +
            run "yarn add swagger-ui"
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,353 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: graphiti-openapi
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Alex Semyonov
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2019-01-21 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: railties
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 5.2.2
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: 5.2.2
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: activemodel
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: responders
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: kaminari
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ">="
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :runtime
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ">="
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: graphiti
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - "~>"
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: 1.0.beta.8
         | 
| 76 | 
            +
              type: :runtime
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - "~>"
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: 1.0.beta.8
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: dry-struct
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - "~>"
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: 0.6.0
         | 
| 90 | 
            +
              type: :runtime
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - "~>"
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: 0.6.0
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: transproc
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - ">="
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
              type: :runtime
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ">="
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: webpacker
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ">="
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 118 | 
            +
              type: :runtime
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ">="
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '0'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: bundler
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - "~>"
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: '2.0'
         | 
| 132 | 
            +
              type: :development
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - "~>"
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '2.0'
         | 
| 139 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 140 | 
            +
              name: rake
         | 
| 141 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 | 
            +
                requirements:
         | 
| 143 | 
            +
                - - "~>"
         | 
| 144 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            +
                    version: '10.0'
         | 
| 146 | 
            +
              type: :development
         | 
| 147 | 
            +
              prerelease: false
         | 
| 148 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 | 
            +
                requirements:
         | 
| 150 | 
            +
                - - "~>"
         | 
| 151 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            +
                    version: '10.0'
         | 
| 153 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            +
              name: rspec
         | 
| 155 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 | 
            +
                requirements:
         | 
| 157 | 
            +
                - - "~>"
         | 
| 158 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            +
                    version: '3.0'
         | 
| 160 | 
            +
              type: :development
         | 
| 161 | 
            +
              prerelease: false
         | 
| 162 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 | 
            +
                requirements:
         | 
| 164 | 
            +
                - - "~>"
         | 
| 165 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            +
                    version: '3.0'
         | 
| 167 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 168 | 
            +
              name: rspec-rails
         | 
| 169 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 170 | 
            +
                requirements:
         | 
| 171 | 
            +
                - - "~>"
         | 
| 172 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 173 | 
            +
                    version: '3.8'
         | 
| 174 | 
            +
              type: :development
         | 
| 175 | 
            +
              prerelease: false
         | 
| 176 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 177 | 
            +
                requirements:
         | 
| 178 | 
            +
                - - "~>"
         | 
| 179 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 180 | 
            +
                    version: '3.8'
         | 
| 181 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 182 | 
            +
              name: rspec-its
         | 
| 183 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 184 | 
            +
                requirements:
         | 
| 185 | 
            +
                - - ">="
         | 
| 186 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 187 | 
            +
                    version: '0'
         | 
| 188 | 
            +
              type: :development
         | 
| 189 | 
            +
              prerelease: false
         | 
| 190 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 191 | 
            +
                requirements:
         | 
| 192 | 
            +
                - - ">="
         | 
| 193 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 194 | 
            +
                    version: '0'
         | 
| 195 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 196 | 
            +
              name: rufo
         | 
| 197 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 198 | 
            +
                requirements:
         | 
| 199 | 
            +
                - - ">="
         | 
| 200 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 201 | 
            +
                    version: '0'
         | 
| 202 | 
            +
              type: :development
         | 
| 203 | 
            +
              prerelease: false
         | 
| 204 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 205 | 
            +
                requirements:
         | 
| 206 | 
            +
                - - ">="
         | 
| 207 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 208 | 
            +
                    version: '0'
         | 
| 209 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 210 | 
            +
              name: pry
         | 
| 211 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 212 | 
            +
                requirements:
         | 
| 213 | 
            +
                - - ">="
         | 
| 214 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 215 | 
            +
                    version: '0'
         | 
| 216 | 
            +
              type: :development
         | 
| 217 | 
            +
              prerelease: false
         | 
| 218 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 219 | 
            +
                requirements:
         | 
| 220 | 
            +
                - - ">="
         | 
| 221 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 222 | 
            +
                    version: '0'
         | 
| 223 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 224 | 
            +
              name: activerecord
         | 
| 225 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 226 | 
            +
                requirements:
         | 
| 227 | 
            +
                - - ">="
         | 
| 228 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 229 | 
            +
                    version: '0'
         | 
| 230 | 
            +
              type: :development
         | 
| 231 | 
            +
              prerelease: false
         | 
| 232 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 233 | 
            +
                requirements:
         | 
| 234 | 
            +
                - - ">="
         | 
| 235 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 236 | 
            +
                    version: '0'
         | 
| 237 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 238 | 
            +
              name: pg
         | 
| 239 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 240 | 
            +
                requirements:
         | 
| 241 | 
            +
                - - ">="
         | 
| 242 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 243 | 
            +
                    version: '0'
         | 
| 244 | 
            +
              type: :development
         | 
| 245 | 
            +
              prerelease: false
         | 
| 246 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 247 | 
            +
                requirements:
         | 
| 248 | 
            +
                - - ">="
         | 
| 249 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 250 | 
            +
                    version: '0'
         | 
| 251 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 252 | 
            +
              name: graphiti_spec_helpers
         | 
| 253 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 254 | 
            +
                requirements:
         | 
| 255 | 
            +
                - - ">="
         | 
| 256 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 257 | 
            +
                    version: '0'
         | 
| 258 | 
            +
              type: :development
         | 
| 259 | 
            +
              prerelease: false
         | 
| 260 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 261 | 
            +
                requirements:
         | 
| 262 | 
            +
                - - ">="
         | 
| 263 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 264 | 
            +
                    version: '0'
         | 
| 265 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 266 | 
            +
              name: factory_bot_rails
         | 
| 267 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 268 | 
            +
                requirements:
         | 
| 269 | 
            +
                - - ">="
         | 
| 270 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 271 | 
            +
                    version: '0'
         | 
| 272 | 
            +
              type: :development
         | 
| 273 | 
            +
              prerelease: false
         | 
| 274 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 275 | 
            +
                requirements:
         | 
| 276 | 
            +
                - - ">="
         | 
| 277 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 278 | 
            +
                    version: '0'
         | 
| 279 | 
            +
            description: OpenAPI 3.0 specification for your (Graphiti) JSON:API
         | 
| 280 | 
            +
            email:
         | 
| 281 | 
            +
            - alex@semyonov.us
         | 
| 282 | 
            +
            executables: []
         | 
| 283 | 
            +
            extensions: []
         | 
| 284 | 
            +
            extra_rdoc_files: []
         | 
| 285 | 
            +
            files:
         | 
| 286 | 
            +
            - ".editorconfig"
         | 
| 287 | 
            +
            - ".gitignore"
         | 
| 288 | 
            +
            - ".rspec"
         | 
| 289 | 
            +
            - ".travis.yml"
         | 
| 290 | 
            +
            - CODE_OF_CONDUCT.md
         | 
| 291 | 
            +
            - Gemfile
         | 
| 292 | 
            +
            - MIT-LICENSE
         | 
| 293 | 
            +
            - README.md
         | 
| 294 | 
            +
            - Rakefile
         | 
| 295 | 
            +
            - app/assets/packs/api.js
         | 
| 296 | 
            +
            - app/controllers/graphiti/open_api/application_controller.rb
         | 
| 297 | 
            +
            - app/controllers/graphiti/open_api/specifications_controller.rb
         | 
| 298 | 
            +
            - app/helpers/graphiti/open_api/application_helper.rb
         | 
| 299 | 
            +
            - app/models/graphiti/open_api/action.rb
         | 
| 300 | 
            +
            - app/models/graphiti/open_api/attribute.rb
         | 
| 301 | 
            +
            - app/models/graphiti/open_api/endpoint.rb
         | 
| 302 | 
            +
            - app/models/graphiti/open_api/functions.rb
         | 
| 303 | 
            +
            - app/models/graphiti/open_api/generator.rb
         | 
| 304 | 
            +
            - app/models/graphiti/open_api/parameters.rb
         | 
| 305 | 
            +
            - app/models/graphiti/open_api/relationship.rb
         | 
| 306 | 
            +
            - app/models/graphiti/open_api/resource.rb
         | 
| 307 | 
            +
            - app/models/graphiti/open_api/schema.rb
         | 
| 308 | 
            +
            - app/models/graphiti/open_api/source.rb
         | 
| 309 | 
            +
            - app/models/graphiti/open_api/struct.rb
         | 
| 310 | 
            +
            - app/models/graphiti/open_api/type.rb
         | 
| 311 | 
            +
            - app/models/graphiti/open_api/types.rb
         | 
| 312 | 
            +
            - app/views/graphiti/open_api/specifications/index.html.erb
         | 
| 313 | 
            +
            - app/views/graphiti/open_api/specifications/index.yaml.erb
         | 
| 314 | 
            +
            - app/views/layouts/graphiti/open_api/application.html.erb
         | 
| 315 | 
            +
            - bin/console
         | 
| 316 | 
            +
            - bin/rails
         | 
| 317 | 
            +
            - bin/setup
         | 
| 318 | 
            +
            - bin/webpack
         | 
| 319 | 
            +
            - config/openapi.yml
         | 
| 320 | 
            +
            - config/routes.rb
         | 
| 321 | 
            +
            - graphiti-openapi.gemspec
         | 
| 322 | 
            +
            - lib/graphiti-openapi.rb
         | 
| 323 | 
            +
            - lib/graphiti/open_api.rb
         | 
| 324 | 
            +
            - lib/graphiti/open_api/engine.rb
         | 
| 325 | 
            +
            - lib/graphiti/open_api/version.rb
         | 
| 326 | 
            +
            - lib/tasks/graphiti_openapi.rake
         | 
| 327 | 
            +
            - lib/templates/installer.rb
         | 
| 328 | 
            +
            homepage: https://github.com/alsemyonov/graphiti-openapi
         | 
| 329 | 
            +
            licenses: []
         | 
| 330 | 
            +
            metadata:
         | 
| 331 | 
            +
              homepage_uri: https://github.com/alsemyonov/graphiti-openapi
         | 
| 332 | 
            +
              source_code_uri: https://github.com/alsemyonov/graphiti-openapi
         | 
| 333 | 
            +
              changelog_uri: https://github.com/alsemyonov/graphiti-openapi/blob/master/CHANGELOG.md
         | 
| 334 | 
            +
            post_install_message: 
         | 
| 335 | 
            +
            rdoc_options: []
         | 
| 336 | 
            +
            require_paths:
         | 
| 337 | 
            +
            - lib
         | 
| 338 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 339 | 
            +
              requirements:
         | 
| 340 | 
            +
              - - ">="
         | 
| 341 | 
            +
                - !ruby/object:Gem::Version
         | 
| 342 | 
            +
                  version: '0'
         | 
| 343 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 344 | 
            +
              requirements:
         | 
| 345 | 
            +
              - - ">="
         | 
| 346 | 
            +
                - !ruby/object:Gem::Version
         | 
| 347 | 
            +
                  version: '0'
         | 
| 348 | 
            +
            requirements: []
         | 
| 349 | 
            +
            rubygems_version: 3.0.2
         | 
| 350 | 
            +
            signing_key: 
         | 
| 351 | 
            +
            specification_version: 4
         | 
| 352 | 
            +
            summary: OpenAPI 3.0 specification for your (Graphiti) JSON:API
         | 
| 353 | 
            +
            test_files: []
         |