Maybe. What is a mongoose schema?

 

 

 

From: <swagger-swaggersocket@googlegroups.com> on behalf of Abezar Baker 
<bizbaker...@gmail.com>
Reply-To: "swagger-swaggersocket@googlegroups.com" 
<swagger-swaggersocket@googlegroups.com>
Date: Wednesday, 31 August 2016 at 06:13
To: Swagger <swagger-swaggersocket@googlegroups.com>
Subject: Can we use mongoose schema when defining the schema in swagger.json ?

 

"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);
-- 
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-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
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-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to