generated from betagouv/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6f1a11
commit 549698f
Showing
19 changed files
with
485 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
Rswag::Api.configure do |config| | ||
# Specify a root folder where Swagger JSON files are located | ||
# This is used by the Swagger middleware to serve requests for API descriptions | ||
# NOTE: If you're using rswag-specs to generate Swagger, you'll need to ensure | ||
# that it's configured to generate files in the same folder | ||
config.openapi_root = Rails.root.join("swagger").to_s | ||
|
||
# Inject a lambda function to alter the returned Swagger prior to serialization | ||
# The function will have access to the rack env for the current request | ||
# For example, you could leverage this to dynamically assign the "host" property | ||
# | ||
# config.swagger_filter = lambda { |swagger, env| swagger['host'] = env['HTTP_HOST'] } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
Rswag::Ui.configure do |config| | ||
# List the Swagger endpoints that you want to be documented through the | ||
# swagger-ui. The first parameter is the path (absolute or relative to the UI | ||
# host) to the corresponding endpoint and the second is a title that will be | ||
# displayed in the document selector. | ||
# NOTE: If you're using rspec-api to expose Swagger files | ||
# (under openapi_root) as JSON or YAML endpoints, then the list below should | ||
# correspond to the relative paths for those endpoints. | ||
|
||
config.swagger_endpoint "/api-docs/v1/#{Rails.application.config.openapi_file.call('v1')}", | ||
"#{Rails.application.config.application_name} API V1 Documentation" | ||
|
||
# Add Basic Auth in case your API is private | ||
# config.basic_auth_enabled = true | ||
# config.basic_auth_credentials 'username', 'password' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require "swagger_helper" | ||
|
||
describe "Profiles API" do | ||
path "/profiles" do | ||
get "Récupérer les profils disponibles" do | ||
tags "Profils" | ||
produces "application/json" | ||
|
||
response "200", "liste des profiles" do | ||
schema type: :object, | ||
properties: { | ||
data: { | ||
type: "array", | ||
data: { type: "#/components/schemas/profile" } | ||
} | ||
}, | ||
required: ["data"] | ||
run_test! | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# frozen_string_literal: true | ||
|
||
require "swagger_helper" | ||
|
||
describe "Devis API" do | ||
path "/quote_checks" do | ||
# TODO: i18n? | ||
post "Téléverser un devis" do | ||
tags "Devis" | ||
# TODO: security [ basic_auth: [] ] | ||
consumes "multipart/form-data" | ||
produces "application/json" | ||
|
||
parameter name: :file, in: :formData, schema: { | ||
type: :string, | ||
format: :binary | ||
}, required: true | ||
parameter name: :profile, in: :formData, schema: { | ||
"$ref" => "#/components/schemas/profile" | ||
}, required: true | ||
|
||
response "201", "Devis téléversé" do | ||
schema "$ref" => "#/components/schemas/quote_check" | ||
description "Au retour le devis a été téléversé avec succès. | ||
Mais vérifiez selon le statut si le devis a été déjà analysé ou non. | ||
Il peut contenir des erreurs dès le téléversement. | ||
Si le statut est 'pending', cela signifie que l'analyse est encore en cours. | ||
Et qu'il faut boucler sur l'appel /quote_check/:id pour récupérer le devis à jour.".gsub("\n", "<br>") | ||
|
||
let(:file) { fixture_file_upload("quote_files/Devis_test.pdf") } | ||
let(:profile) { "artisan" } | ||
|
||
run_test! | ||
end | ||
|
||
response "422", "invalid request" do | ||
let(:file) { fixture_file_upload("quote_files/Devis_test.pdf") } | ||
let(:profile) { "blabla" } | ||
|
||
run_test! | ||
end | ||
end | ||
end | ||
|
||
path "/quote_checks/{id}" do | ||
get "Récupérer un Devis" do | ||
tags "Devis" | ||
consumes "application/json" | ||
produces "application/json" | ||
parameter name: :id, in: :path, type: :string, required: true | ||
|
||
response "200", "Devis trouvé" do | ||
schema "$ref" => "#/components/schemas/quote_check" | ||
|
||
let(:id) { create(:quote_check).id } | ||
|
||
run_test! | ||
end | ||
|
||
response "404", "Devis non trouvé" do | ||
let(:id) { SecureRandom.uuid } | ||
|
||
run_test! | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.