Skip to content

Commit 6101b79

Browse files
committed
Move detailed documentation from README to docs/
- Move Documentation Options table to docs/documentation-options.md - Simplify Development and Contributing sections to reference docs/ - Keep README focused on quick start examples
1 parent 28eb8ce commit 6101b79

2 files changed

Lines changed: 91 additions & 27 deletions

File tree

README.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
- [Compatibility](#compatibility)
1111
- [Installation](#installation)
1212
- [Usage](#usage)
13-
- [Basic Entity](#basic-entity)
14-
- [Custom Model Description](#custom-model-description)
15-
- [Entity References](#entity-references)
16-
- [Documentation Options](#documentation-options)
1713
- [Development](#development)
1814
- [Contributing](#contributing)
1915
- [License](#license)
@@ -124,35 +120,17 @@ end
124120

125121
### Documentation Options
126122

127-
The following options are available in the `documentation` hash:
128-
129-
| Option | Description |
130-
|--------|-------------|
131-
| `type` | OpenAPI data type (`String`, `Integer`, `Boolean`, etc.) |
132-
| `desc` | Property description |
133-
| `required` | Whether field is required (default: based on expose options) |
134-
| `is_array` | Marks field as array type |
135-
| `read_only` | Marks field as read-only |
136-
| `values` | Enum values for the field |
137-
| `example` | Example value |
138-
| `default` | Default value |
139-
| `minimum` | Minimum value for numeric types |
140-
| `maximum` | Maximum value for numeric types |
141-
| `min_length` | Minimum length for string types |
142-
| `max_length` | Maximum length for string types |
143-
| `hidden` | Hide field from documentation |
123+
Common options: `type`, `desc`, `required`, `is_array`, `values`, `example`.
144124

145-
## Development
125+
See [full documentation options](docs/documentation-options.md) for all available options including validation constraints.
146126

147-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/pry` for an interactive prompt that will allow you to experiment.
127+
## Development
148128

149-
To install this gem onto your local machine, run `bundle exec rake install`.
129+
See [testing documentation](docs/testing.md) for development setup and running tests.
150130

151131
## Contributing
152132

153-
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-grape/grape-swagger-entity.
154-
155-
See [CONTRIBUTING](CONTRIBUTING.md) for more information.
133+
See [contributing guidelines](docs/contributing.md).
156134

157135
## License
158136

docs/documentation-options.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Documentation Options
2+
3+
The `documentation` hash in entity exposures supports the following options:
4+
5+
## Type Options
6+
7+
| Option | Description | Example |
8+
|--------|-------------|---------|
9+
| `type` | OpenAPI data type | `String`, `Integer`, `Boolean`, `Float`, `Date`, `DateTime` |
10+
| `is_array` | Marks field as array type | `true` / `false` |
11+
12+
## Description Options
13+
14+
| Option | Description | Example |
15+
|--------|-------------|---------|
16+
| `desc` | Property description | `'User email address'` |
17+
| `example` | Example value for documentation | `'user@example.com'` |
18+
| `default` | Default value | `'pending'` |
19+
20+
## Validation Options
21+
22+
| Option | Description | Example |
23+
|--------|-------------|---------|
24+
| `required` | Whether field is required | `true` / `false` |
25+
| `values` | Enum values (array or proc) | `%w[pending active]` or `-> { Status.all }` |
26+
| `minimum` | Minimum value for numeric types | `0` |
27+
| `maximum` | Maximum value for numeric types | `100` |
28+
| `min_length` | Minimum length for strings | `1` |
29+
| `max_length` | Maximum length for strings | `255` |
30+
31+
## Display Options
32+
33+
| Option | Description | Example |
34+
|--------|-------------|---------|
35+
| `read_only` | Marks field as read-only | `true` |
36+
| `hidden` | Hide field from documentation | `true` |
37+
38+
## Examples
39+
40+
### Basic types
41+
42+
```ruby
43+
expose :id, documentation: { type: Integer, desc: 'Unique identifier' }
44+
expose :name, documentation: { type: String, desc: 'Full name', required: true }
45+
expose :active, documentation: { type: Boolean, default: true }
46+
```
47+
48+
### Enums
49+
50+
```ruby
51+
expose :status, documentation: {
52+
type: String,
53+
desc: 'Current status',
54+
values: %w[pending active suspended]
55+
}
56+
```
57+
58+
### Numeric constraints
59+
60+
```ruby
61+
expose :age, documentation: {
62+
type: Integer,
63+
minimum: 0,
64+
maximum: 150
65+
}
66+
```
67+
68+
### String constraints
69+
70+
```ruby
71+
expose :username, documentation: {
72+
type: String,
73+
min_length: 3,
74+
max_length: 20
75+
}
76+
```
77+
78+
### Arrays
79+
80+
```ruby
81+
expose :tags, documentation: {
82+
type: String,
83+
is_array: true,
84+
desc: 'Associated tags'
85+
}
86+
```

0 commit comments

Comments
 (0)