1.0.5 • Published 4 years ago

openapi-mongoose v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

OPENAPI-MONGOOSE


Generate mongoose schemas and models from openApi 3.0 documents.

USAGE


Simply pass your OpenApi document to the compile method, and then dynamically access the underlying mongoose models.

var results = require('openapi-mongoose').compile(YAML.load('./openapi.yaml'));

console.log(results);

var Pet  = mongoose.model('Pets');

var myPet = new Pet({
  id: 123,
  name: 'Fluffy'
});

Using ref structure

Advice: for relative paths don't use './', write directly the path from the current directory as show in the example:

# File: ./openapi.yaml
# Models
components:  
  schemas:  
    $ref: 'models/index.yaml'
# File: ./models/index.yaml
example:      
  $ref: 'example.yaml'
error: 
  $ref: 'error.yaml'
# File: ./models/example.yaml

description: Example
type: object
required:
  - id
  - name
properties:
  id:
    type: integer
    format: int64
  name:
    type: string
  tag:
    type: string 
  age:
    type: integer
    format: int32
    minimum: 0

Opena api document

Allows types:

  • number
  • integer
  • long
  • float
  • double
  • string
  • password
  • boolean
  • date
  • dateTime
  • array
Pets:
    type: object
    required:
    - id
    - name
    properties:
    id:
        type: integer
        format: int64
    name:
        type: string
    tag:
        type: string      

REFERENCES

payapi-swagger-mongoose

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago