Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-cli-openapi-generate

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-openapi-generate

Automatically generate Ember models from OpenAPI definitions.

  • 0.0.15
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

ember-cli-openapi-generate

Generate Ember models from an OpenAPI schema.

Installation

ember install ember-cli-openapi-generate

Usage

Generate from a web-accessible swagger.json

$ ember openapi http://petstore.swagger.io/v2/swagger.json

Or, generate from a local file

$ ember openapi /path/to/your/swagger.json

An arraytype option is available. Use this when you have an array transform created and want to have regular string/int arrays as attribute type when parsing models through openapi.json files.

$ ember openapi http://petstore.swagger.io/v2/swagger.json --arraytype

The difference between a regular generate command and the arraytype generate command is shown in the following example.

diff --git a/app/models/pet.js b/app/models/pet.js
index 6249237..517e5c2 100644
--- a/app/models/pet.js
+++ b/app/models/pet.js
@@ -3,7 +3,7 @@ import DS from 'ember-data';
 export default DS.Model.extend({
   category: DS.belongsTo('category'),
   name: DS.attr('string'),
-  photoUrls: DS.hasMany('photo-url'),
+  photoUrls: DS.attr('array'),
   tags: DS.hasMany('tag'),
   status: DS.attr('string')
 });

Options

(Under development)

  • --cli Only generate ember g model style output.
  • --resource Use resources (ember g resource) rather than only models (which will create models, routes and templates).
  • --arraytype Use an array transform (see Usage notes).

Rationale

You can easily spin up a JSONAPI compliant Node/Express server backed by Mongo (along with other datastores) with jsonapi-server. By adding a swagger configuration option you can provide an OpenAPI schema for the models you've created. All in all there is a lot of duplication in creating JOI models for the server and then data models for Ember. This Ember addon means that you can automate the creation of the Ember models and optionally use it to update them when the API changes.

References

Keywords

FAQs

Package last updated on 09 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc