Skip to content

Instantly share code, notes, and snippets.

@DWS-paris
Last active February 18, 2022 10:42
Show Gist options
  • Save DWS-paris/cbb54f50bd8327b02816b69f4095c0e7 to your computer and use it in GitHub Desktop.
Save DWS-paris/cbb54f50bd8327b02816b69f4095c0e7 to your computer and use it in GitHub Desktop.
const openapiSpecification = {
openapi: "3.0.0",
info: {
title: "Popcorn Movie API",
description: "Popcon Movie is a school project realized to manipulate API technology in Javascript.",
specification: "https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md",
contact: {
name: "API Support",
email: "[email protected]"
},
license: {
name: "Apache 2.0",
url: "https://www.apache.org/licenses/LICENSE-2.0.html"
},
version: "0.0.1",
},
server: {
url: `${process.env.OPENAPI_URL}`,
description: "Development server",
variables: {
port: { default: process.env.OPENAPI_PORT },
basePath: { default: process.env.OPENAPI_VERSION }
},
components: {
securitySchemes: {
cookieAuth: {
type: "token",
description: "JWT token generated by API",
in: "cookie",
name: "popcorn-token"
},
serverAuth: {
type: "origin",
description: "Allow access to specific server origin",
in: "headers"
}
}
},
paths: {
[`${process.env.OPENAPI_VERSION}/auth/register`]: {
post: {
security: [],
summary: "Used to register new user",
model: "identity",
schema: "IdentityDto",
operator: {
id: "registerOperator",
type: "function"
},
requestBody: {
required: true,
content: "application/json",
type: "object",
mandatory: {
email: { type: "string", description: "Email associated to the IdentityDto" },
password: { type: "string", description: "Password associated to the IdentityDto" },
potentialAction: { type: "string", description: "IdentityDto role", enum: ['admin', 'lorem', 'ipsum'] },
},
optional: {
familyname: { type: "string", description: "User family name" },
givenname: { type: "string", description: "User given name" },
isBanished: { type: "boolean", description: "Define if user is banish or not" },
},
crypted: ['familyname', 'givenname']
}
}
},
[`${process.env.OPENAPI_VERSION}/auth/login`]: {
post: {
security: [],
summary: "Used to login user",
model: "identity",
schema: "IdentityDto",
operator: {
id: "loginOperator",
type: "function"
},
requestBody: {
required: true,
content: "application/json",
type: "object",
mandatory: {
email: { type: "string", description: "Email associated to the IdentityDto" },
password: { type: "string", description: "Password associated to the IdentityDto" },
},
}
}
},
[`${process.env.OPENAPI_VERSION}/auth/logout`]: {
get: {
security: ["cookieAuth"],
summary: "Used to logout user",
model: "identity",
schema: "IdentityDto",
operator: {
id: "logoutOperator",
type: "function"
},
requestBody: {
required: true,
}
}
},
[`${process.env.OPENAPI_VERSION}/auth/token`]: {
get: {
security: ['cookieAuth'],
summary: "Used to extract IdentityDto from client request token",
model: "identity",
schema: "IdentityDto",
operator: {
id: "jwtExtractOperator",
type: "function"
},
requestBody: {
required: false,
},
}
}
},
[`${process.env.OPENAPI_VERSION}/auth/update`]: {
put: {
security: ['cookieAuth'],
summary: "Used to update IdentityDto password",
model: "identity",
schema: "IdentityDto",
operator: {
id: "updateIdentityOperator",
type: "function"
},
requestBody: {
required: true,
content: "application/json",
type: "object",
mandatory: {
password: { type: "string", description: "Password associated to the IdentityDto" },
newpassword: { type: "string", description: "New password value" },
},
optional: {
potentialAction: { type: "string", description: "IdentityDto role", enum: ['lorem', 'ipsum'] },
}
}
}
},
[`${process.env.OPENAPI_VERSION}/bookmark`]: {
get: {
security: [],
summary: "Used get bookmark list",
model: "bookmark",
schema: "BookmarkDto",
operator: {
id: "crudReadOperator",
type: "function"
},
requestBody: {
required: false,
}
},
post: {
security: ['cookieAuth'],
summary: "Used to create new BookmarkDto",
model: "bookmark",
schema: "BookmarkDto",
operator: {
id: "crudCreateOperator",
type: "function"
},
requestBody: {
required: true,
content: "application/json",
type: "object",
mandatory: {
description: { type: "string", description: "Description of the movie" },
thumbnailUrl: { type: "string", description: "Thumbnail of the movie" },
title: { type: "string", description: "Title of the movie" },
},
optional: {
sameAs: { type: "string", description: "Link to the full movie description (IMDB/ALLOCINE)" },
upVote: { type: "number", description: "Note (IMDB/ALLOCINE) of the movie" },
},
}
}
},
[`${process.env.OPENAPI_VERSION}/bookmark/:uuid`]: {
delete: {
security: ['cookieAuth'],
summary: "Used delete one bookmark",
model: "bookmark",
schema: "BookmarkDto",
operator: {
id: "crudDeleteOperator",
type: "function"
},
parameters: {
name: "uuid",
required: true,
schema: {
type: "string",
description: "UUID of the BookmarkDto to get in response"
}
},
requestBody: {
required: false,
}
},
get: {
security: [],
summary: "Used get one bookmark by UUID",
model: "bookmark",
schema: "BookmarkDto",
operator: {
id: "crudReadOperator",
type: "function"
},
parameters: {
name: "uuid",
required: true,
schema: {
type: "string",
description: "UUID of the BookmarkDto to get in response"
}
},
requestBody: {
required: false,
}
},
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment