Skip to content

Instantly share code, notes, and snippets.

@wreulicke
Last active November 30, 2017 22:46
Show Gist options
  • Save wreulicke/b4dba3d5a2d506d164110b049d2076e0 to your computer and use it in GitHub Desktop.
Save wreulicke/b4dba3d5a2d506d164110b049d2076e0 to your computer and use it in GitHub Desktop.
mdconfで遊んだ
'use strict'
const parse = require('mdconf')
const fs = require('fs')
const path = require('path')
const promisify = require('util').promisify
const readFile = promisify(fs.readFile)
readFile(path.resolve('.', process.argv[2]))
.then(data => console.log(JSON.stringify(parse(data.toString()), null, 2)))
.catch(console.log)

This markfown describes a JSON Schema for package.json. Using mdconf.

  • $ref: #/definitions/schema

Definitions

Schema

This is schema for package.json

  • type: object
  • title: schema

Properties

root of package.json has some propertie

Name

This is module name.

  • type: string

Version

This is package version.

  • type: string

Description

This is package description

  • type: string

Main

The main field is a module ID that is the primary entry point to your program.

  • type: string

Keywords

This helps people discover your package as it's listed in 'npm search'.

  • type: array
Items
  • type: string

Author

  • type: string

License

You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it.

  • type: string

Dependencies

Required

Listed followings is required

  • name

Dependencies

Dependencies are specified with a simple hash of package name to version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.

  • type: object
  • title: dependencies

This markdown provides swagger.json using mdconf

  • swagger: 2.0
  • host: api.example.com
  • basePath: /v1

Info

  • title: Example API
  • description: Move your app forward with the Example API
  • version: 1.0.0

Schemes

  • https

Produces

  • application/json

Paths

/me

get

  • summary: User Profile
  • description: The User Profile endpoint returns information.

Responses

200
  • description: Profile information for a user
Schema
  • $ref: #/definitions/profile
Default
  • description: Unexpected error
Schema
  • $ref: #/definitions/error

Definitions

Profile

  • type: object

Properties

First_name

  • type: string
  • description: First name of the user.

Last_name

  • type: string
  • description: Last name of the user.

email

  • type: string
  • description: Email address of the Uber user

Error

  • type: object

Properties

Code

  • type: integer
  • format: int32

Message

  • type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment