-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2 nls wrapper endpoint; use minimal observation association loading
- Loading branch information
Showing
4 changed files
with
67 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const _ = require( "lodash" ); | ||
const languageSearchSchema = require( "../../../schema/request/language_search" ); | ||
const transform = require( "../../../joi_to_openapi_parameter" ); | ||
const computervisionController = require( "../../../../lib/controllers/v1/computervision_controller" ); | ||
|
||
module.exports = sendWrapper => { | ||
async function GET( req, res ) { | ||
const results = await computervisionController.languageSearch( req ); | ||
sendWrapper( req, res, null, results ); | ||
} | ||
|
||
GET.apiDoc = { | ||
tags: ["Computer Vision"], | ||
summary: "Fetch language demo search results for a search term", | ||
security: [{ | ||
appOrUserJwtRequired: [] | ||
}], | ||
"x-unpublished": true, | ||
parameters: _.map( | ||
languageSearchSchema.$_terms.keys, child => ( | ||
transform( child.schema.label( child.key ) ) | ||
) | ||
), | ||
responses: { | ||
200: { | ||
description: "An array of language demo search results", | ||
content: { | ||
"application/json": { | ||
schema: { | ||
$ref: "#/components/schemas/ResultsLanguageSearch" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
return { | ||
GET | ||
}; | ||
}; |
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,10 @@ | ||
const Joi = require( "joi" ); | ||
|
||
module.exports = Joi.object( ).keys( { | ||
q: Joi.string( ), | ||
taxon_id: Joi.array( ).items( Joi.number( ).integer( ) ), | ||
locale: Joi.string( ), | ||
page: Joi.number( ).integer( ), | ||
per_page: Joi.number( ).integer( ), | ||
fields: Joi.any( ) | ||
} ).unknown( false ).meta( { unpublished: true } ); |
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 @@ | ||
const Joi = require( "joi" ); | ||
const observation = require( "./observation" ); | ||
|
||
module.exports = Joi.object( ).keys( { | ||
total_results: Joi.number( ).integer( ).required( ), | ||
page: Joi.number( ).integer( ).required( ), | ||
per_page: Joi.number( ).integer( ).required( ), | ||
results: Joi.array( ).items( | ||
Joi.object( { | ||
photo_id: Joi.number( ).integer( ).required( ), | ||
score: Joi.number( ).required( ), | ||
observation | ||
} ) | ||
).required( ) | ||
} ).unknown( false ).meta( { unpublished: true } ); |