/
dereferencing_through_inlining.feature
103 lines (96 loc) 路 2.77 KB
/
dereferencing_through_inlining.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Feature: $ref defererencing through inlining
Background:
Given a checked file "lurker/api/v3/users/__id-PATCH.json.yml" with:
"""yml
---
description: user updating
prefix: users management
requestParameters:
description: ''
type: object
additionalProperties: false
required: []
properties:
user:
"$ref": "../../../definitions/user_request_parameters.json#/"
responseCodes:
- status: 200
successful: true
description: ''
responseParameters:
"$ref": "../../../definitions/user.json#/"
extensions:
method: PATCH
path_info: "/api/v3/users/1"
path_params:
controller: api/v3/users
action: update
id: '1'
"""
And a file named "lurker/definitions/user_request_parameters.json" with:
"""json
{
"properties": {
"name": {
"type": "string",
"example": "Bob"
}
}
}
"""
And a file named "lurker/definitions/user.json.yml" with:
"""yml
---
properties:
id:
type: integer
example: 1
name:
type: string
example: razum2um
surname:
type: string
example: Unknown
"""
And a file named "spec/controllers/api/v3/users_controller_spec.rb" with:
"""ruby
require "spec_helper"
describe Api::V3::UsersController, :lurker do
render_views
let(:user) do
User.where(name: 'razum2um', surname: 'Unknown').first_or_create!
end
it "updates a user surname as string" do
patch :update, id: user.id, user: { surname: 'Marley' }
expect(response).to be_success
end
end
"""
Scenario: json schema left $ref keyword as is using "users/update"
When I run `bin/rspec spec/controllers/api/v3/users_controller_spec.rb`
Then the example should pass
Then a file named "lurker/api/v3/users/__id-PATCH.json.yml" should exist
Then the checked file "lurker/api/v3/users/__id-PATCH.json.yml" should not change
Then a file named "lurker/definitions/user_request_parameters.json" should exist
Then the file "lurker/definitions/user_request_parameters.json" should contain exactly:
"""json
{
"properties": {
"name": {
"type": "string",
"example": "Bob",
"description": ""
},
"surname": {
"description": "",
"type": "string",
"example": "Marley"
}
},
"description": "",
"type": "object",
"additionalProperties": false,
"required": [
]
}
"""