Skip to content

Commit

Permalink
Merge pull request #39 from 4ormat/condensed-syntax
Browse files Browse the repository at this point in the history
Condensed syntax - inline keys support, optional blocks
  • Loading branch information
fotinakis committed Jan 29, 2016
2 parents 5228074 + 6bbe7c5 commit 28fbd20
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 163 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,34 @@ The `key` block simply takes the value you give and puts it directly into the fi
key :foo, {some_complex: {nested_object: true}}
```

#### Inline keys

It is possible to condensed syntax to omit numerous `key` calls using hash argument.

All three calls are equal:

```ruby
parameter do
key :paramType, :path
key :name, :petId
key :description, 'ID of pet that needs to be fetched'
key :type, :string
end
```

```ruby
parameter paramType: :path, name: :petId do
key :description, 'ID of pet that needs to be fetched'
key :type, :string
end
```

```ruby
parameter paramType: :path, name: :petId,
description: 'ID of pet that needs to be fetched',
type: :string
```

#### Writing JSON to a file

If you are not serving the JSON directly and need to write it to a file for some reason, you can easily use `build_root_json` for that as well:
Expand Down
Loading

0 comments on commit 28fbd20

Please sign in to comment.