Can we use mongoose schema when defining the schema in swagger.json ?

124 views
Skip to first unread message

Abezar Baker

unread,
Aug 31, 2016, 9:13:27 AM8/31/16
to Swagger
"paths": {
"/testing": {
"post": {
"tags": [
"testing"
],
"summary": "",
"description": "Add a test",
"parameters": [
{
"name": "body",
"in": "body",
"description": "",
"required": true,
"schema": {
"$ref": "#/definitions/SomeSchema" //can we instead point to the mongoose schema in my project so that i dont violate DRY
}
}
],
"responses": {
"200": {},
"400": {
"description": "Invalid request"
}
}
},
}

"definitions": {
"SomeSchema": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"example": "hello"
}
}
}
}


Example mongoose schema:
'use strict';

let mongoose = require('mongoose');
let Schema = mongoose.Schema;

let testSchema = new Test({
name: {
type: String,
required: true
}
}, {
collection: 'test',
versionKey: false
});

module.exports = mongoose.model('Test', testSchema);

Ron Ratovsky

unread,
Sep 20, 2016, 7:30:32 PM9/20/16
to swagger-sw...@googlegroups.com

Maybe. What is a mongoose schema?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages