在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:interagent/prmd开源软件地址:https://github.com/interagent/prmd开源编程语言:Ruby 84.8%开源软件介绍:PrmdJSON Schema tooling: scaffold, verify, and generate documentation from JSON Schema documents. IntroductionJSON Schema provides a great way to describe an API. prmd provides tools for bootstrapping a description like this, verifying its completeness, and generating documentation from the specification. To learn more about JSON Schema in general, start with this excellent guide and supplement with the specification. The JSON Schema usage conventions expected by prmd specifically are described in /docs/schemata.md. InstallationInstall the command-line tool with: $ gem install prmd If you're using prmd within a Ruby project, you may want to add it to the application's Gemfile: gem 'prmd' $ bundle install UsagePrmd provides four main commands:
Here's an example of using these commands in a typical workflow: # Fill out the resource schemata
$ mkdir -p schemata
$ prmd init app > schemata/app.json
$ prmd init user > schemata/user.json
$ vim schemata/{app,user}.json # edit scaffolded files
# Provide top-level metadata
$ cat <<EOF > meta.json
{
"description": "Hello world prmd API",
"id": "hello-prmd",
"links": [{
"href": "https://api.hello.com",
"rel": "self"
}],
"title": "Hello Prmd"
}
EOF
# Combine into a single schema
$ prmd combine --meta meta.json schemata/ > schema.json
# Check it’s all good
$ prmd verify schema.json
# Build docs
$ prmd doc schema.json > schema.md Using YAML instead of JSON as a resource and meta format
# Generate resources in YAML format
$ prmd init --yaml app > schemata/app.yml
$ prmd init --yaml user > schemata/user.yml
# Combine into a single schema
$ prmd combine --meta meta.json schemata/ > schema.json
Render from schema$ prmd render --template schemata.erb schema.json > schema.md Typically you'll want to prepend header and overview information to
your API documentation. You can do this with the $ prmd doc --prepend overview.md schema.json > schema.md You can also chain commands together as needed, e.g.: $ prmd combine --meta meta.json schemata/ | prmd verify | prmd doc --prepend overview.md > schema.md See Documentation rendering settingsOut of the box you can supply a settings file (in either $ prmd doc --settings config.json schema.json > schema.md Available options (and their defaults) {
"doc": {
"url_style": "default", // can also be "json"
"disable_title_and_description": false, // remove the title and the description, useful when using your own custom header
"toc": false // insert the table of content for json scheme documentation to the top of the file. (default disable)
}
} Use as rake taskIn addition, prmd can be used via rake tasks # Rakefile
require 'prmd/rake_tasks/combine'
require 'prmd/rake_tasks/verify'
require 'prmd/rake_tasks/doc'
namespace :schema do
Prmd::RakeTasks::Combine.new do |t|
t.options[:meta] = 'schema/meta.json' # use meta.yml if you prefer YAML format
t.paths << 'schema/schemata/api'
t.output_file = 'schema/api.json'
end
Prmd::RakeTasks::Verify.new do |t|
t.files << 'schema/api.json'
end
Prmd::RakeTasks::Doc.new do |t|
t.files = { 'schema/api.json' => 'schema/api.md' }
end
end
task default: ['schema:combine', 'schema:verify', 'schema:doc'] File LayoutWe suggest the following file layout for JSON schema related files:
where Contributing
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论