Commit a67814d3 authored by Quentin David's avatar Quentin David
Browse files

Update swagger code

parent 8cc100aa
......@@ -65,60 +65,4 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Pipeline'
components:
schemas:
User:
type: object
description: User is beautiful.
properties:
name:
type: string
description: Name of the user
mail:
type: string
description: Mail address of the user
password:
type: string
description: Password of the user
Process:
type: object
description: Instructions for a module to execute given a list of parameters
properties:
moduleName:
type: String
description: Name of the module that execute the process
moduleParameter:
type: array
description: A parameter for the module that execute the process
items:
type: object
properties:
name:
type: String
description: Name of the parameter
value:
type: String
description: Value of the parameter
Pipeline:
type: object
description: A list of process to execute on a corpus
properties:
corpusId:
type: String
description: Id of the corpus attached to that process
currentProcessingModule:
type: String
description: Name of the module that is being executed currently by the pipeline. Is null if the pipeline has not started, failed, or finished.
status:
type: String
enum:
- Not started yet
- Started
- Finished
- Failed
description: Status of the pipeline
processes:
type: array
items:
$ref: '#/components/schemas/Process'
\ No newline at end of file
......@@ -8,6 +8,42 @@ const mongoose = require('mongoose');
const Schema = mongoose.Schema;
/**
* @swagger
* components:
* schemas:
* Output:
* type: object
* description: data returned by a module at the end of a process
* required:
* - processId
* - moduleName
* - content.data
* properties:
* processId:
* type: String
* description: id of process that generated that output
* moduleName:
* type: String
* description: name of the module that generated that output
* content:
* type: object
* description: contains the information of the output
* properties:
* title:
* type: String
* description: a text given to describe the output
* example: Neologisms found by Neoveille
* description:
* type: String
* description: more text to detail the output
* example: 'This is the result of the module SDMC given those parameters: ....'
* data:
* type: String
* description: the content produced by the module
* example: macronisme\nadulescent\ncapilotracté
*/
// Output returned by a module
// Can be a text file or something else like a model.
/* Should there be documentId or corpusId? */
......@@ -20,7 +56,47 @@ const OutputSchema = new Schema({
data: { type: String, required: true}
}
});
/**
* @swagger
* components:
* schemas:
* Annotation:
* type: object
* description: contains the annotation produced for a given process for a single document
* required:
* - documentId
* - processId
* - moduleName
* - content.data
* properties:
* documentId:
* type: String
* description: id of the document whose annotation is attached
* processId:
* type: String
* description: id of the process whose annotation is attached
* moduleName:
* type: String
* description: name of the module that produced this annotation
* content:
* type: object
* description: contains the information of the annotation
* properties:
* title:
* type: String
* description: a text given to describe the annotation
* description:
* type: String
* description: more text to detail the annotation
* data:
* type: String
* description: the actual annotations produced by a process
* color:
* type: String
* description: the color that will be used to highlight annotated tokens
*/
// An annotation is the conjunction of a module and a document.
// It must contains all the informations needed for the visualisation tool to work.
const AnnotationSchema = new Schema({
......@@ -35,6 +111,27 @@ const AnnotationSchema = new Schema({
color: { type: String }
})
/**
* @swagger
* components:
* schemas:
* Document:
* type: object
* description: a part of a corpus, if the user chose multiple files
* properties:
* corpusId:
* type: String
* description: the corpus from which the document comes
* source:
* type: String
* description: the original text of the document, unannotated
* annotations:
* type: array
* description: all the annotations of a document
* items:
* $ref: "#/components/schemas/Annotation"
*/
// Documents are build at the end of the pipeline
// It contains the source text and
// the annotations added by a pipeline
......@@ -44,18 +141,89 @@ const DocumentSchema = new Schema({
annotations: { type: [AnnotationSchema] }
})
/**
* @swagger
* components:
* schemas:
* ConlluColumn:
* type: object
* description: the content of a column following ConLLu-Plus conventions
* required:
* - columnTitle
* - columnData
* properties:
* columnTitle:
* type: String
* description: the text corresponding to the head of the column
* example: UPOS
* columnData:
* type: String
* description: the data corresponding to the conllu annotation, where each row is the annotation of a token
* example: ADV\nVERB\nPRON\nNUM\nNOUN\nPUNCT
*
*/
// The content of a column with ConLLU-Plus style, each row corresponding to a token.
const ConLLuColumnSchema = new Schema({
const ConlluColumnSchema = new Schema({
columnId: {type: String }, // Needed ?
columnTitle: { type: String, required: true},
columnData: { type: String, required: true}
})
/**
* @swagger
* components:
* schemas:
* Metadata:
* type: object
* description: contains informations about a corpus
* properties:
* author:
* type: String
* description: name of the entity that produced the corpus
* example: Howard Phillips Lovecraft
* title:
* type: String
* description: title given to the corpus
* example: The Call of Cthulhu
* description:
* type: String
* description: more details about the corpus
* example: Full text of the book by LoveCraft scraped from a pdf.
* date:
* type: Date
* description: date of creation of the corpus
* example: 1928
* type:
* type: String
* description: categorization of the corpus
* example: short story
* size:
* type: String
* description: weight of the corpus in bytes
* example: 20Mb
* userMetadata:
* type: array
* description: list of metadata added by the user
* items:
* type: object
* description: pair of the name of a metadata and its value
* properties:
* name:
* type: String
* description: title of a metadata added by the user
* value:
* type: String
* description: value of a metadata added by the user
*/
// Informations about a corpus
const MetadataSchema = new Schema({
author: {type: String },
title: {type: String },
description: {type: String },
date: {type: String },
date: {type: Date },
type: {type: String },
size: {type: String },
userMetadata: [{
......@@ -64,15 +232,51 @@ const MetadataSchema = new Schema({
}]
})
// A corpus is composed of those attributes
/**
* @swagger
* components:
* schemas:
* Corpus:
* type: object
* description: a text that will be processed through a pipeline
* properties:
* pipelineId:
* type: String
* description: id of the pipeline that processes that corpus
* conlluColumns:
* type: array
* description: list of columns, representing the whole conllu file
* items:
* $ref: "#/components/schemas/ConlluColumn"
* outputs:
* type: array
* description: list of outputs produced by the pipeline that processed that corpus
* items:
* $ref: "#/components/schemas/Output"
* documents:
* type: array
* description: list of documents that compose the corpus, used for the visualisation tool
* items:
* $ref: "#/components/schemas/Document"
* createdBy:
* type: String
* description: '"userId" if created by a user or "public"'
* creationDate:
* type: Date
* description: the date of creation of the corpus to the database
* metadata:
* $ref: "#/components/schemas/Metadata"
*/
// A text that will be used for a pipeline
const CorpusSchema = new Schema({
corpusId: { type: String},
//corpusId: { type: String},
pipelineId: { type: String }, // What happens if there is two pipeline
conlluColumns: { type: [ConLLuColumnSchema]},
conlluColumns: { type: [ConlluColumnSchema]},
outputs: { type: [OutputSchema]},
documents: { type: [DocumentSchema]},
createdBy: { type: String}, // userId or public
creationDate : { type: String },
creationDate : { type: Date },
metadata: { type: MetadataSchema }
});
// Let's compile as a model
......
......@@ -6,11 +6,40 @@ const mongoose = require('mongoose');
const Schema = mongoose.Schema;
/**
* @swagger
* components:
* schemas:
* Process:
* type: object
* description: Instructions for a module to execute given a list of parameters
* properties:
* moduleName:
* type: String
* description: Name of the module that execute the process
* example: SDMC
* moduleParameters:
* type: array
* description: A parameter for the module that execute the process
* example: [{ name: 'motif_type', value: 'Forme du mot seul'},{name: 'motif_representation', value: 'Fermés (sans sous-motifs de même fréquence)'}]
* items:
* type: object
* properties:
* name:
* type: String
* description: Name of the parameter
* example: motif_type
* value:
* type: String
* description: Value of the parameter
* example: Forme du mot seul
*/
// A process contains the information needed for a module to be executed
/* Should it contains corpusId? */
const ProcessSchema = new Schema({
moduleName: { type: String, required: true},
moduleParameter: {
moduleParameters: {
type:
[{
name: String,
......@@ -20,16 +49,72 @@ const ProcessSchema = new Schema({
}
})
/**
* @swagger
* components:
* schemas:
* Pipeline:
* type: object
* description: A list of process to execute on a corpus
* properties:
* corpusId:
* type: String
* description: Id of the corpus attached to that process
* preTreatments:
* type: object
* description: contains the information about the pre-treatment for the pipeline
* properties:
* sentenceSegmentation:
* type: Boolean
* description: should the corpus be segmented into sentences?
* wordSegmentation:
* type: Boolean
* description: should the corpus be segmented into words?
* posTagger:
* type: Boolean
* description: should each token be anotated with its part-of-speech?
* conversionToUTF:
* type: Boolean
* description: should the corpus be converted to UTF?
* currentProcessingModule:
* type: String
* description: Name of the module that is being executed currently by the pipeline. Is null if the pipeline has not started, failed, or finished.
* status:
* type: String
* enum:
* - Not started yet
* - Started
* - Finished
* - Failed
* description: Status of the pipeline
* processes:
* type: array
* items:
* $ref: '#/components/schemas/Process'
* creationDate:
* type: Date
* description: The date where the corpus has been added to the database
* description:
* type: String
* description: Some text to describe the use of the pipeline
*/
// A pipeline contains the instruction to apply one or several
// modules to a corpus.
const PipelineSchema = new Schema({
corpusId: { type: String, required: true },
preTreatments: {
sentenceSegmentation: Boolean,
wordSegmentation: Boolean,
posTagger: Boolean,
conversionToUTF: Boolean // imprecise... which UTF?
},
currentProcessingModule: { type: String }, // What module is currently processing the corpus?
status: {
type: String,
enum: ['Not started yet', 'Started', 'Finished', 'Failed']
},
processes: { type: [ProcessSchema] , required: true},
creationDate: { type: String },
creationDate: { type: Date },
description: { type: String }
})
\ No newline at end of file
......@@ -6,20 +6,73 @@ const mongoose = require('mongoose');
const Schema = mongoose.Schema;
/**
* @swagger
* components:
* schemas:
* User:
* type: object
* description: Identity of an user
* properties:
* name:
* type: String
* description: user's name or nickname
* example: JohnDoe
* mail:
* type: String
* description: user's e-mail address
* example: john@doe.com
* password:
* type: String
* description: user's password (hashed?)
* example: mylittlepony42
* status:
* type: String
* enum:
* - User
* - Admin
* description: user's status
* example: User
* profileCorpora:
* type: array
* description: list of corpora added by the user
* items:
* type: String
* pipelines:
* type: array
* description: list of pipelines executed by the user
* items:
* type: object
* properties:
* pipelineId:
* type: String
* description: id of a pipeline executed by the user
* status:
* type: String
* description: status of a pipeline executed by the user
* config:
* type: object
* description: diverse configurations of a user
* properties:
* sendMailWhenPipelineFinished:
* type: Boolean
* description: asserts if the user wants to receive a mail when a pipeline it executed have been finished.
*/
// A user is composed of those attributes
const UserSchema = new Schema({
name: { type: String},
mail: { type: String},
password: { type: String },
status: {
type: String,
enum: ['User','Admin']
},
profileCorpora: {type: [{ corpusId: String }]},
pipelines: { type: [{pipelineId: String, status: String}]},
config: {
sendMailWhenPipelineFinished: { type: Boolean, default: true}
}
name: { type: String},
mail: { type: String},
password: { type: String },
status: {
type: String,
enum: ['User','Admin']
},
profileCorpora: {type: [{ corpusId: String }]},
pipelines: { type: [{pipelineId: String, status: String}]},
config: {
sendMailWhenPipelineFinished: { type: Boolean, default: true}
}
});
// Let's compile as a model
......
......@@ -6,7 +6,7 @@ const modulesRoutes = require('./routes/modules.js');
const usersRoutes = require('./routes/users.js')
const swaggerUi = require("swagger-ui-express");
//var swaggerJsdoc = require("swagger-jsdoc");
const swaggerJsdoc = require("swagger-jsdoc");
const YAML = require('yamljs');
const swaggerDocument = YAML.load('./config/swagger.yaml');
......@@ -58,12 +58,16 @@ app.use('/users', usersRoutes);
// },
// apis: ["./routes/*.js", "./models/*.js"]
// };
//const specs = swaggerJsdoc(options);
const options = {
definition: swaggerDocument,
apis: ["./routes/*.js", "./models/*.js"]
}
const specs = swaggerJsdoc(options);
app.use(
"/api-docs",
swaggerUi.serve,
swaggerUi.setup(swaggerDocument, { explorer: true} )
swaggerUi.setup(specs, { explorer: true} )
);
app.listen(port, () => console.log(`App listening at http://localhost:${port}`));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment