From bcbcf9b469f4992928077d4e352d6caa89e39f67 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Fri, 15 Nov 2024 18:28:45 +0100 Subject: [PATCH] MVP of swagger documentation --- .gitignore | 3 +++ Dockerfile.dev | 2 +- config/initializers/rswag_ui.rb | 2 +- spec/requests/groups_spec.rb | 19 +++++++++++++++++++ spec/swagger_helper.rb | 4 ++-- 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 spec/requests/groups_spec.rb diff --git a/.gitignore b/.gitignore index 5fb66c9..13e3051 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ # Ignore master key for decrypting credentials and more. /config/master.key + +# Ignore swagger generated documentation +swagger/v1/swagger.yaml diff --git a/Dockerfile.dev b/Dockerfile.dev index 792a1ce..f911e52 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,7 +1,7 @@ # syntax = docker/dockerfile:1 # Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile -ARG RUBY_VERSION=3.3.5 +ARG RUBY_VERSION=3.3.6 FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base # Rails app lives here diff --git a/config/initializers/rswag_ui.rb b/config/initializers/rswag_ui.rb index 1d6151b..30172aa 100644 --- a/config/initializers/rswag_ui.rb +++ b/config/initializers/rswag_ui.rb @@ -8,7 +8,7 @@ Rswag::Ui.configure do |c| # (under openapi_root) as JSON or YAML endpoints, then the list below should # correspond to the relative paths for those endpoints. - c.swagger_endpoint '/api-docs/v1/swagger.yaml', 'API V1 Docs' + c.swagger_endpoint '/api/api-docs/v1/swagger.yaml', 'API V1 Docs' # Add Basic Auth in case your API is private # c.basic_auth_enabled = true diff --git a/spec/requests/groups_spec.rb b/spec/requests/groups_spec.rb new file mode 100644 index 0000000..4dcfd71 --- /dev/null +++ b/spec/requests/groups_spec.rb @@ -0,0 +1,19 @@ +require 'swagger_helper' + +RSpec.describe 'groups', type: :request do + path '/groups' do + get('list groups') do + response(200, 'successful') do + + after do |example| + example.metadata[:response][:content] = { + 'application/json' => { + example: JSON.parse(response.body, symbolize_names: true) + } + } + end + run_test! + end + end + end +end diff --git a/spec/swagger_helper.rb b/spec/swagger_helper.rb index 14c1214..2cae0bb 100644 --- a/spec/swagger_helper.rb +++ b/spec/swagger_helper.rb @@ -24,10 +24,10 @@ RSpec.configure do |config| paths: {}, servers: [ { - url: 'https://{defaultHost}', + url: 'http://{defaultHost}/api', variables: { defaultHost: { - default: 'www.example.com' + default: 'libre-wedding-planner.app.localhost' } } }