No commit activity in last 3 years
No release in over 3 years
Generates swagger-ui json file for rails-api
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
>= 1.7.3, ~> 1.7
~> 0.34.2
>= 4.2.8, ~> 4.2
~> 10.0
>= 4.2.4, ~> 4.2
~> 3.5
~> 0.48.1
>= 1.8.4, ~> 1.8
~> 0.9.5

Runtime

 Project Readme

Swagger::Docs::Generator | Travis Gem Docs

Generator for Swagger Apps (Example with theme)

Menu

  • How to use
    • Installation
    • Usage
  • Development
  • Contributing

How to use

Installation

Add this line to your application's Gemfile :

gem 'swagger-docs-generator'

And then execute :

bundle

Or install it yourself as :

gem install swagger_docs_generator

Usage

Create initializer :

rails generator swagger_docs_generator:initializer

Create environment :

rails generator swagger_docs_generator:environment

Execute rake task for generated swagger.json :

rake swagger:docs

Examples

# frozen_string_literal: true

module V1
  # Documentation API for AddressesController
  class AddressesDoc < BaseDoc
    CONTROLLER = V1::Geos::AddressesController

    # Describe object Addresses
    # ###
    scontroller 'User Addresses management'

    # Describe all actions
    # ###
    sdoc :show do
      summary 'Show address'
      responses do
        status 200
        schema { definition 'address' }
      end
      responses { status 404 }
      responses { status 422 }
      description <<EOS
  # Show address to user

  Show complete address to user.
EOS
    end

    sdoc :create do
      summary 'Create address'
      responses { status 201 }
      responses { status 422 }
      parameters do
        body do
          name 'address'
          schema 'address create'
        end
      end
      description <<EOS
  # Add address

  Save an address to user.
EOS
    end

    sdoc :update do
      summary 'Update address'
      responses do
        status 200
        schema { definition 'address' }
      end
      responses { status 404 }
      responses { status 422 }
    end

    sdoc :destroy do
      summary 'Destroy address'
      responses do
        status 200
        schema { definition 'address' }
      end
      responses { status 404 }
      responses { status 422 }
    end

    # Add definition more model
    # ###
    sdefinition 'address create' do
      required %w[address]
      properties do
        required %w{country city zip_code street}
        properties country: { type: :string },
                   city: { type: :string },
                   zip_code: { type: :string },
                   street: { type: :string },
                   complements: { type: :string }
      end
    end

    sdefinition 'address' do
      required %w[address]
      properties do
        properties country: { type: :string },
                   city: { type: :string },
                   zip_code: { type: :string },
                   street: { type: :string },
                   complements: { type: :string },
                   coordinates: { type: :string }
      end
    end
  end
end

Development

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.

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Dev-Crea/swagger-docs-generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.