2.0.93 • Published 8 years ago

swagger-model v2.0.93

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

Swagger Model

This repository is no longer maintained. The schema has been diverged from Swagger 2.0 standard as a result of requirement change in the internal project which used this library.

Generate Javascript model class code from swagger definition and convert between JSON and model instance

Build Status Coverage Status Dependency Status

Installation

npm install swagger-model --save-dev (for class file generation)

bower install swagger-model (for runtime)

Usage

Compile time (generator.js)

generate(swaggerDefinition, outPath | option)

Generate Javascript class files from swagger definition

  • swaggerDefinition: JSON of Swagger definition
  • outPath: Output path string OR option: Detailed options
  option: {
    outPath: 'Output path',
    filters: [
      'Array of regular expression strings, generate if class name matches the regexp. eg: "^includeThisClass$"'
      'Skip class if class name matches expression begins with `!`.  eg: "!^skipThisClass$"'
    ]
  }

Runtime (runtime.js)

register(className, definition) or register(definition)

Register a swagger model class so when converting from JSON or to JSON the library knows where to find the class

  • className: String of class name
  • definition: Constractor function of a model class

isRegistered(className)

Check if a model class has been registered

json2Model(object, className, options)

Build model instance from JSON object

  • object: A JSON object
  • className: The model class name you are mapping to
  • options:
{
    // Specify property name of the objectID
    // Json with same objectID will share same object in model instance
    objectID: 'ID'
}

model2Json(object)

Build JSON object from model instance

  • object: Model object

isModel(object)

Determine if object is a model instance

clone(object)

Make deep clone of a model instance

Test

npm test
2.0.93

8 years ago

2.0.92

8 years ago

2.0.90

9 years ago

2.0.89

9 years ago

2.0.88

9 years ago

2.0.87

9 years ago

2.0.84

9 years ago

2.0.83

9 years ago

2.0.82

9 years ago

2.0.80

9 years ago

2.0.78

9 years ago

2.0.77

9 years ago

2.0.76

9 years ago

2.0.75

9 years ago

2.0.74

9 years ago

2.0.73

9 years ago

2.0.72

9 years ago

2.0.71

9 years ago

2.0.70

9 years ago

2.0.69

9 years ago

2.0.68

9 years ago

2.0.67

9 years ago

2.0.66

9 years ago

2.0.65

9 years ago

2.0.63

9 years ago

2.0.62

9 years ago

2.0.61

9 years ago

2.0.60

9 years ago

2.0.59

9 years ago

2.0.58

9 years ago

2.0.57

9 years ago

2.0.56

9 years ago

2.0.55

9 years ago

2.0.54

9 years ago

2.0.53

9 years ago

2.0.52

9 years ago

2.0.51

9 years ago

2.0.50

9 years ago

2.0.49

9 years ago

2.0.48

9 years ago

2.0.46

9 years ago

2.0.45

9 years ago

2.0.44

9 years ago

2.0.43

9 years ago

2.0.41

9 years ago

2.0.40

9 years ago

2.0.39

9 years ago

2.0.38

9 years ago

2.0.37

9 years ago

2.0.36

9 years ago

2.0.35

9 years ago

2.0.34

9 years ago

2.0.33

9 years ago

2.0.32

9 years ago

2.0.31

9 years ago

2.0.30

9 years ago

2.0.29

9 years ago

2.0.28

9 years ago

2.0.27

9 years ago

2.0.26

9 years ago

2.0.25

9 years ago

2.0.23

9 years ago

2.0.22

9 years ago

2.0.21

9 years ago

2.0.20

9 years ago

2.0.18

9 years ago

2.0.17

9 years ago

2.0.15

9 years ago

2.0.14

9 years ago

2.0.12

9 years ago

2.0.11

9 years ago

2.0.10

9 years ago

2.0.9

9 years ago

2.0.8

9 years ago

2.0.7

9 years ago

2.0.6

9 years ago

2.0.5

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago