From dc64032206aa09aaff4bbd13d3af87172e695020 Mon Sep 17 00:00:00 2001 From: Jakub Pavlik Date: Tue, 11 Jun 2024 23:35:28 +0200 Subject: [PATCH 1/3] update usage documentation --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e0a7555..610e433 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,16 @@ Set up environment running bin/rails graphiti:openapi:install ``` -Configure OpenAPI template in `config/openapi.yml` and Graphiti::OpenAPI will pick your resources schema and -translate it to OpenAPI 3.0 JSON and YAML files, providing Swagger UI with live API documentation. - ## Usage Edit template in `config/openapi.yml` to customize your OpenAPI output. This file will be used as base for resulting -document. +document. Generate it by executing + +```bash +bin/rails graphiti:openapi:generate +``` + +Results will be saved in `public/api/v1/openapi.json` and `public/api/v1/openapi.yaml` ## Development From 7ea6a47821d6099aa849b75988744a89edf13289 Mon Sep 17 00:00:00 2001 From: Jakub Pavlik Date: Tue, 11 Jun 2024 23:38:09 +0200 Subject: [PATCH 2/3] delete unused code --- lib/graphiti/open_api.rb | 2 -- lib/graphiti/open_api/engine.rb | 5 ----- lib/templates/installer.rb | 7 ------- 3 files changed, 14 deletions(-) diff --git a/lib/graphiti/open_api.rb b/lib/graphiti/open_api.rb index 829f0d4..c9dc21c 100644 --- a/lib/graphiti/open_api.rb +++ b/lib/graphiti/open_api.rb @@ -2,8 +2,6 @@ module Graphiti module OpenApi - class Error < StandardError - end end end diff --git a/lib/graphiti/open_api/engine.rb b/lib/graphiti/open_api/engine.rb index ff76604..44c7ae8 100644 --- a/lib/graphiti/open_api/engine.rb +++ b/lib/graphiti/open_api/engine.rb @@ -1,15 +1,10 @@ require "rails" -require "responders" require "graphiti" module Graphiti module OpenApi class Engine < ::Rails::Engine isolate_namespace Graphiti::OpenApi - - initializer "graphiti.openapi.init" do - Mime::Type.register "text/yaml", :yaml - end end end end diff --git a/lib/templates/installer.rb b/lib/templates/installer.rb index 1a2fe45..b5186b3 100644 --- a/lib/templates/installer.rb +++ b/lib/templates/installer.rb @@ -1,8 +1,4 @@ root = File.expand_path("../..", __dir__) -packs = File.directory?("app/assets/packs") ? "app/assets/packs" : "app/javascripts/packs" - -say "Copying api.js to #{packs}/" -copy_file "#{root}/app/assets/packs/api.js", "#{packs}/api.js" say "Copying openapi.yml to config/" copy_file "#{root}/config/openapi.yml", "config/openapi.yml" @@ -15,6 +11,3 @@ public/api/v1/openapi.yaml IGNORE end - -say "Installing JavaScript dependencies" -run "yarn add swagger-ui" From 124d03317c0a7edef1bcb10b14c2f387bbe68a4a Mon Sep 17 00:00:00 2001 From: Jakub Pavlik Date: Wed, 12 Jun 2024 19:37:27 +0200 Subject: [PATCH 3/3] output paths depend on Graphiti configuration --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 610e433..b7249ff 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ document. Generate it by executing bin/rails graphiti:openapi:generate ``` -Results will be saved in `public/api/v1/openapi.json` and `public/api/v1/openapi.yaml` +Results will be saved in `public/#{ApplicationResource.endpoint_namespace}/openapi.json` and `.../openapi.yaml` ## Development