Coder Social home page Coder Social logo

rswag_schema_export's Introduction

Rswag::Schema::Export

CircleCI

Export your schema.json file to AWS S3/Azure Blob storage and import back after deploy.

Installation

Add this line to your application's Gemfile:

gem 'rswag_schema_export'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rswag_schema_export
$ rails g rswag_schema_export:install

Set up

# config/initializers/rswag_schema_export.rb
RswagSchemaExport.configure do |c|
+  c.schemas = ['swagger/client/swagger.json', 'swagger/backoffice/swagger.json']
+  c.client = :aws
end

Lifecycle

swaggerize -> export to cloud storage -> deploy -> import from cloud storage

Export example with CI

.gitlab-ci.yml
stages:
  - test
  - export_api_doc
  - deploy
test:
  tags:
  - shell-ruby
  before_script:
    - RAILS_ENV=test bundle exec rails db:create db:migrate
  script:
    - rspec
  artifacts:
    paths:
      - coverage/
  after_script:
    - RAILS_ENV=test bundle exec rails db:drop
rswag_schema_export:
  dependencies: []
  stage: export_api_doc
  before_script:
    - RAILS_ENV=test bundle exec rails db:create
  tags:
  - shell-ruby
  script:
  - rails db:schema:load rswag:specs:swaggerize RAILS_ENV=test
  - STAGE=develop rails rswag:schema_export
develop:
  dependencies: []
  stage: deploy
  tags:
  - shell-ruby
  script:
  - bundle exec cap develop deploy
  only:
  - develop

Import example with Capistrano

# Capfile
require 'rswag_schema_export/capistrano'
# config/deploy.rb
+ append :linked_dirs, "swagger"
# config/deploy/production.rb
+ set :rswag_schema_export_disable_import, true

Slack notifications

# config/deploy/develop.rb
+ set :rswag_schema_export_slack_webhook_url, ENV.fetch('SLACK_WEBHOOK_URL')

Configuration

Set up ENVIRONMENT VARIABLES on your CI

# Required for AWS
RSWAG_AWS_ACCESS_KEY_ID='' # Example: XXXXXXXXXX
RSWAG_AWS_SECRET_ACCESS_KEY='' # Example: XXXXXXXXXXXXXXXXXXXXX
RSWAG_AWS_REGION='' # Example: us-west-1
RSWAG_AWS_BUCKET='' # Example: bucket-name

# Required for AZURE

RSWAG_AZURE_STORAGE_ACCOUNT_NAME='' # Example: XXXXX
RSWAG_AZURE_STORAGE_ACCESS_KEY='' # Example: XXXXXXXXXXXXXXXXXXXXX
RSWAG_AZURE_CONTAINER='' # Example: continter-name

# Optional
STAGE='' # Default: develop
APP_NAME='' # Default: app

Gitlab Variables

image

rswag-api

# config/initializers/rswag_api.rb
Rswag::Api.configure do |c|
+  c.swagger_root = Rails.root.to_s + '/swagger'
end

Contributing

  1. Fork it ( link )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

The MIT License

About MLSDev

MLSdev

The repo is maintained by MLSDev, Inc. We specialize in providing all-in-one solution in mobile and web development. Our team follows Lean principles and works according to agile methodologies to deliver the best results reducing the budget for development and its timeline.

Find out more here and don't hesitate to contact us!

rswag_schema_export's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

dmytrostepaniuk

rswag_schema_export's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.