New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

naptime

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

naptime

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Naptime

Describe your data model using JSON and have naptime spit out the RESTful API endpoints.

Why do this?

Often times when I start a project, I end up designing the API before thinking through the completeness of my data. This way, I can imagine exactly what I want my data entity to look like using JSON and have naptime output all the relevant RESTful API endpoints.

How to use

Create a file that contains your JSON description, eg. example.json and run:

ruby naptime.rb example.json

Example

Here we created a file person.json that contains the following description:

{
  "name": "Richard",
  "gender": "male",
  "siblings": {
    "brother": {
      "name": "John",
      "birthdate" : "5/1/1972"
    },
    "sister": "Sarah"
  },
  "address": {
    "street": "582 S Grade",
    "city": "Alpine"
  },
  "employed": "yes"
}

Then we ran ruby naptime.rb person.json and got the following output:

POST /person
{"name":"Richard","gender":"male","employed":"yes"}

GET /person/[id]

POST /person/[id]
{"name":"Richard","gender":"male","employed":"yes"}

DELETE /person/[id]

POST /person/[id]/siblings
{"sister":"Sarah"}

GET /person/[id]/siblings/[id]

POST /person/[id]/siblings/[id]
{"sister":"Sarah"}

DELETE /person/[id]/siblings/[id]

POST /person/[id]/siblings/[id]/brother
{"name":"John","birthdate":"5/1/1972"}

GET /person/[id]/siblings/[id]/brother/[id]

POST /person/[id]/siblings/[id]/brother/[id]
{"name":"John","birthdate":"5/1/1972"}

DELETE /person/[id]/siblings/[id]/brother/[id]

POST /person/[id]/address
{"street":"582 S Grade","city":"Alpine"}

GET /person/[id]/address/[id]

POST /person/[id]/address/[id]
{"street":"582 S Grade","city":"Alpine"}

DELETE /person/[id]/address/[id]

This output describes the necessary API endpoints to do the CRUD for the described data entity.

FAQs

Package last updated on 20 Nov 2014

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