Skip to content

Commit

Permalink
Document output
Browse files Browse the repository at this point in the history
  • Loading branch information
Braktar committed Jun 1, 2021
1 parent cae1302 commit 64685da
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
8 changes: 8 additions & 0 deletions api/v01/entities/vrp_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ class VrpResult < Grape::Entity
expose :job, using: VrpResultJob, documentation: { desc: 'The Job status' }
end

class VrpSyncJob < Grape::Entity
expose :solutions, using: VrpResultSolution, documentation: { is_array: true, desc: 'The current best solution' }
end

class VrpAsyncJob < Grape::Entity
expose :job, using: VrpResultJob, documentation: { desc: 'The Job status' }
end

class VrpJobsList < Grape::Entity
expose :jobs, using: VrpResultJob, documentation: { is_array: true, desc: 'The Jobs' }
end
Expand Down
26 changes: 21 additions & 5 deletions api/v01/vrp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,24 @@ class Vrp < APIBase
desc 'Submit VRP problem', {

nickname: 'submit_vrp',
success: VrpResult,
failure: [
{ code: 400, message: 'Bad Request', model: ::Api::V01::Status }
],
success: [{
code: 200,
message: 'The VRP has been processed synchronously',
model: VrpSyncJob
}, {
code: 201,
message: 'The VRP has been placed in a queue to be processed',
model: VrpAsyncJob
}],
failure: [{
code: 400,
message: 'Bad Request',
model: ::Api::V01::Status
}, {
code: 413,
message: 'Exceeded limit authorized for your account. Please contact support or sales to increase limits.',
model: ::Api::V01::Status
}],
detail: 'Submit vehicle routing problem. If the problem can be quickly solved, the solution is returned in the response. In other case, the response provides a job identifier in a queue: you need to perfom another request to fetch vrp job status and solution.'
}
params {
Expand Down Expand Up @@ -196,7 +210,9 @@ class Vrp < APIBase

desc 'Delete vrp job', {
nickname: 'deleteJob',
success: { code: 204 },
success: {
code: 202,
model: VrpResult},
failure: [
{ code: 404, message: 'Not Found', model: ::Api::V01::Status }
],
Expand Down

0 comments on commit 64685da

Please sign in to comment.