Coder Social home page Coder Social logo

okobsamoht / ember-cli-openapi-generate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from queenvictoria/ember-cli-openapi-generate

0.0 2.0 0.0 95 KB

Automatically generate Ember models from OpenAPI definitions.

License: MIT License

JavaScript 88.01% HTML 11.99%

ember-cli-openapi-generate's Introduction

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

ember-cli-openapi-generate's People

Contributors

queenvictoria avatar pauln avatar eriktrom avatar mariobrosch avatar ember-tomster avatar tech-bear avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.