Skip to content

Commit

Permalink
fix swagger/openapi validation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pleary committed Mar 5, 2024
1 parent b197ca4 commit 69453a2
Show file tree
Hide file tree
Showing 17 changed files with 243 additions and 12 deletions.
3 changes: 1 addition & 2 deletions lib/views/swagger_v1.yml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,7 @@ paths:
- identification
- observation
default: identification
- order:
name: order
- name: order
type: string
in: query
description: Sort order
Expand Down
11 changes: 11 additions & 0 deletions openapi/paths/v2/announcements/{id}/dismiss.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const Joi = require( "joi" );
const transform = require( "../../../../joi_to_openapi_parameter" );
const AnnouncementsController = require( "../../../../../lib/controllers/v1/announcements_controller" );

module.exports = sendWrapper => {
Expand All @@ -12,6 +14,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.number( ).integer( )
.label( "id" )
.meta( { in: "path" } )
.required( )
.description( "A single ID" )
)
],
responses: {
204: {
description: "No response body; success implies dismissal"
Expand Down
20 changes: 20 additions & 0 deletions openapi/paths/v2/comments/{uuid}.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const Joi = require( "joi" );
const transform = require( "../../../joi_to_openapi_parameter" );
const CommentsController = require( "../../../../lib/controllers/v2/comments_controller" );

module.exports = sendWrapper => {
Expand All @@ -12,6 +14,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
requestBody: {
content: {
"application/json": {
Expand Down Expand Up @@ -46,6 +57,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
responses: {
200: {
description: "No response body; success implies deletion"
Expand Down
20 changes: 20 additions & 0 deletions openapi/paths/v2/identifications/{uuid}.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const Joi = require( "joi" );
const transform = require( "../../../joi_to_openapi_parameter" );
const IdentificationsController = require( "../../../../lib/controllers/v2/identifications_controller" );

module.exports = sendWrapper => {
Expand All @@ -12,6 +14,15 @@ module.exports = sendWrapper => {
security: [{
userJwtOptional: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
requestBody: {
content: {
"application/json": {
Expand Down Expand Up @@ -48,6 +59,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
responses: {
200: {
description: "No response body; success implies deletion"
Expand Down
20 changes: 20 additions & 0 deletions openapi/paths/v2/observation_field_values/{uuid}.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const Joi = require( "joi" );
const transform = require( "../../../joi_to_openapi_parameter" );
const observationFieldValuesController = require( "../../../../lib/controllers/v2/observation_field_values_controller" );

module.exports = sendWrapper => {
Expand All @@ -12,6 +14,15 @@ module.exports = sendWrapper => {
security: [{
userJwtOptional: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
requestBody: {
content: {
"application/json": {
Expand Down Expand Up @@ -46,6 +57,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
responses: {
204: {
description: "Observation field value deleted"
Expand Down
20 changes: 20 additions & 0 deletions openapi/paths/v2/observation_photos/{uuid}.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const Joi = require( "joi" );
const transform = require( "../../../joi_to_openapi_parameter" );
const ObservationPhotosController = require( "../../../../lib/controllers/v2/observation_photos_controller" );

module.exports = sendWrapper => {
Expand All @@ -12,6 +14,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
requestBody: {
content: {
"application/json": {
Expand Down Expand Up @@ -46,6 +57,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
responses: {
200: {
description: "No response body; success implies deletion"
Expand Down
20 changes: 20 additions & 0 deletions openapi/paths/v2/observation_sounds/{uuid}.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const Joi = require( "joi" );
const transform = require( "../../../joi_to_openapi_parameter" );
const ObservationSoundsController = require( "../../../../lib/controllers/v2/observation_sounds_controller" );

module.exports = sendWrapper => {
Expand All @@ -12,6 +14,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
requestBody: {
content: {
"application/json": {
Expand Down Expand Up @@ -46,6 +57,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
responses: {
200: {
description: "No response body; success implies deletion"
Expand Down
18 changes: 18 additions & 0 deletions openapi/paths/v2/observations/{uuid}.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
requestBody: {
content: {
"multipart/form-data": {
Expand Down Expand Up @@ -94,6 +103,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
responses: {
200: {
description: "No response body; success implies deletion"
Expand Down
11 changes: 11 additions & 0 deletions openapi/paths/v2/photos/{id}.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const Joi = require( "joi" );
const transform = require( "../../../joi_to_openapi_parameter" );
const PhotosController = require( "../../../../lib/controllers/v2/photos_controller" );

module.exports = sendWrapper => {
Expand All @@ -12,6 +14,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.number( ).integer( )
.label( "id" )
.meta( { in: "path" } )
.required( )
.description( "A single ID" )
)
],
responses: {
200: {
description: "An array of photos.",
Expand Down
20 changes: 20 additions & 0 deletions openapi/paths/v2/project_observations/{uuid}.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const Joi = require( "joi" );
const transform = require( "../../../joi_to_openapi_parameter" );
const ProjectObservationsController = require( "../../../../lib/controllers/v2/project_observations_controller" );

module.exports = sendWrapper => {
Expand All @@ -12,6 +14,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
requestBody: {
content: {
"application/json": {
Expand Down Expand Up @@ -49,6 +60,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.string( ).guid( )
.label( "uuid" )
.meta( { in: "path" } )
.required( )
.description( "A single UUID" )
)
],
responses: {
200: {
description: "No response body; success implies deletion"
Expand Down
20 changes: 20 additions & 0 deletions openapi/paths/v2/relationships/{id}.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const Joi = require( "joi" );
const transform = require( "../../../joi_to_openapi_parameter" );
const RelationshipsController = require( "../../../../lib/controllers/v2/relationships_controller" );

module.exports = sendWrapper => {
Expand All @@ -12,6 +14,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.number( ).integer( )
.label( "id" )
.meta( { in: "path" } )
.required( )
.description( "A single ID" )
)
],
requestBody: {
content: {
"application/json": {
Expand Down Expand Up @@ -46,6 +57,15 @@ module.exports = sendWrapper => {
security: [{
userJwtRequired: []
}],
parameters: [
transform(
Joi.number( ).integer( )
.label( "id" )
.meta( { in: "path" } )
.required( )
.description( "A single ID" )
)
],
responses: {
200: {
description: "No response body; success implies deletion"
Expand Down
8 changes: 1 addition & 7 deletions openapi/paths/v2/taxa/suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ module.exports = sendWrapper => {
schema: {
type: "string"
}
},
transform(
Joi.string( )
.label( "image_url" )
.uri( )
.description( "URL for image to use when `source` is `visual`" )
)
}
].concat( _.map( taxaSuggestSchema.$_terms.keys, child => (
transform( child.schema.label( child.key ) )
) ) ),
Expand Down
7 changes: 7 additions & 0 deletions openapi/paths/v2/taxa/{id}/wanted.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ module.exports = sendWrapper => {
child => transform( child.schema.label( child.key ) )
);
parameters.push(
transform(
Joi.number( ).integer( )
.label( "id" )
.meta( { in: "path" } )
.required( )
.description( "A single ID" )
),
transform( Joi.string( ).label( "X-HTTP-Method-Override" ).meta( { in: "header" } ) )
);

Expand Down
Loading

0 comments on commit 69453a2

Please sign in to comment.