Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jorge Garcia flores
ChêneTAL
Commits
a67814d3
Commit
a67814d3
authored
Oct 06, 2020
by
Quentin David
Browse files
Update swagger code
parent
8cc100aa
Changes
5
Show whitespace changes
Inline
Side-by-side
server/config/swagger.yaml
View file @
a67814d3
...
...
@@ -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
server/models/Corpus.js
View file @
a67814d3
...
...
@@ -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? */
...
...
@@ -21,6 +57,46 @@ const OutputSchema = new Schema({
}
});
/**
* @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
Con
LL
uColumnSchema
=
new
Schema
({
const
Con
ll
uColumnSchema
=
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
:
[
Con
LL
uColumnSchema
]},
conlluColumns
:
{
type
:
[
Con
ll
uColumnSchema
]},
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
...
...
server/models/Pipeline.js
View file @
a67814d3
...
...
@@ -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
:
{
moduleParameter
s
:
{
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
server/models/User.js
View file @
a67814d3
...
...
@@ -6,6 +6,59 @@ 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
},
...
...
server/server.js
View file @
a67814d3
...
...
@@ -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
(
s
waggerDocument
,
{
explorer
:
true
}
)
swaggerUi
.
setup
(
s
pecs
,
{
explorer
:
true
}
)
);
app
.
listen
(
port
,
()
=>
console
.
log
(
`App listening at http://localhost:
${
port
}
`
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment