swaggard 4.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddc21f0ceaac51adcd841ded044bc82165d666e1dc0fb832f86577a02839f21e
4
- data.tar.gz: 1140599ec5d0ef899782beb4aec529ca642114eae19509638c4672a23b2982f7
3
+ metadata.gz: 8cd440c54fb4a517bedb134570c0dd76ed67ef1ef1947d0bcd89dc72f70d89a8
4
+ data.tar.gz: cdc795955a2d5d3d89e570657da280fa6fb4873a5bd562f086def5871c035354
5
5
  SHA512:
6
- metadata.gz: 0daa594c72416c1620e20d37da32ad90d4b5c6b5a3e16c8ff063366318d9f4d70c101675c249c23f4ad17b80d77975e5e52c251b9f259a8fae7577c9ac278f45
7
- data.tar.gz: 813fc4f48af7ed3ee726820257f8410247fd96e0059797b6dccc0958b3d0dbb6503c19cb825ce0ddd46125419a365096276f805d88de020d652a247f8255e5b6
6
+ metadata.gz: e0789daceebcc72d62aca37584b4a2163bc1d5de00d20e22d990a8556797492d29fda8ac85acdbacbfde76b8c985047db02b656e0c91686ac386be7b4c9f088f
7
+ data.tar.gz: d860cfcc26f4c3a6c241fb5409ed3077c8330023b171b6c8a729e300056166ee58afd94020f43598d271b488c12ec1192265cbcc8ac2d2ed8bbd62677b3be959
@@ -44,6 +44,8 @@ module Swaggard
44
44
  body_parameter.title = value
45
45
  when 'body_definition'
46
46
  body_parameter.definition = value
47
+ when 'body_content_type'
48
+ body_parameter.content_type = value
47
49
  when 'body_parameter'
48
50
  body_parameter.add_property(value)
49
51
  when 'parameter_list'
@@ -7,11 +7,14 @@ module Swaggard
7
7
  class Body < Base
8
8
  attr_reader :definition
9
9
 
10
+ attr_writer :content_type
11
+
10
12
  def initialize(operation_name)
11
13
  @in = 'body'
12
14
  @name = 'body'
13
15
  @is_required = false
14
16
  @description = ''
17
+ @content_type = 'application/json'
15
18
  @definition = Definition.new("#{operation_name}_body")
16
19
  @definition_id = @definition.id
17
20
  end
@@ -22,14 +25,14 @@ module Swaggard
22
25
  end
23
26
 
24
27
  def empty?
25
- @definition.empty?
28
+ @definition.empty? && @definition_id == @definition.id
26
29
  end
27
30
 
28
31
  def to_request_body
29
32
  {
30
33
  'required' => @is_required,
31
34
  'content' => {
32
- 'application/json' => {
35
+ @content_type => {
33
36
  'schema' => { '$ref' => "#/components/schemas/#{Swaggard.ref_name(@definition_id)}" }
34
37
  }
35
38
  }
@@ -1,3 +1,3 @@
1
1
  module Swaggard
2
- VERSION = '4.0.1'
2
+ VERSION = '4.0.3'
3
3
  end
data/lib/swaggard.rb CHANGED
@@ -30,6 +30,7 @@ module Swaggard
30
30
  ::YARD::Tags::Library.define_tag('Body description', :body_description)
31
31
  ::YARD::Tags::Library.define_tag('Body title', :body_title)
32
32
  ::YARD::Tags::Library.define_tag('Body definition', :body_definition)
33
+ ::YARD::Tags::Library.define_tag('Body content type', :body_content_type)
33
34
  ::YARD::Tags::Library.define_tag('Body parameter', :body_parameter)
34
35
  ::YARD::Tags::Library.define_tag('Parameter list', :parameter_list)
35
36
  ::YARD::Tags::Library.define_tag('Response class', :response_class)
@@ -57,6 +57,30 @@
57
57
  "description": "successful operation"
58
58
  }
59
59
  }
60
+ },
61
+ "post": {
62
+ "tags": [
63
+ "pets"
64
+ ],
65
+ "operationId": "create",
66
+ "summary": "create a new Pet",
67
+ "description": "",
68
+ "parameters": [],
69
+ "responses": {
70
+ "default": {
71
+ "description": "successful operation"
72
+ }
73
+ },
74
+ "requestBody": {
75
+ "required": true,
76
+ "content": {
77
+ "application/json": {
78
+ "schema": {
79
+ "$ref": "#/components/schemas/PetBody"
80
+ }
81
+ }
82
+ }
83
+ }
60
84
  }
61
85
  },
62
86
  "/pets/{id}": {
@@ -107,5 +131,27 @@
107
131
  }
108
132
  }
109
133
  }
134
+ },
135
+ "components": {
136
+ "schemas": {
137
+ "PetBody": {
138
+ "type": "object",
139
+ "properties": {
140
+ "name": {
141
+ "type": "string",
142
+ "description": "The name of the Pet"
143
+ },
144
+ "age": {
145
+ "type": "integer",
146
+ "format": "int32",
147
+ "description": "The age of the Pet"
148
+ }
149
+ }
150
+ },
151
+ "PetsController.create_body": {
152
+ "type": "object",
153
+ "properties": {}
154
+ }
155
+ }
110
156
  }
111
157
  }
@@ -13,4 +13,11 @@ class PetsController < ApplicationController
13
13
  def show
14
14
  end
15
15
 
16
+ # create a new Pet
17
+ #
18
+ # @body_required
19
+ # @body_definition PetBody
20
+ def create
21
+ end
22
+
16
23
  end
@@ -0,0 +1,3 @@
1
+ # @attr [string] name The name of the Pet
2
+ # @attr [integer] age The age of the Pet
3
+ class PetBody; end
@@ -1,6 +1,6 @@
1
1
  Dummy::Application.routes.draw do
2
2
 
3
- resources :pets, only: [:index, :show]
3
+ resources :pets, only: [:index, :show, :create]
4
4
 
5
5
  namespace :admin do
6
6
  resources :pets, only: :index
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swaggard
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Gomez
@@ -152,6 +152,7 @@ files:
152
152
  - spec/fixtures/dummy/app/controllers/admin/pets_controller.rb
153
153
  - spec/fixtures/dummy/app/controllers/application_controller.rb
154
154
  - spec/fixtures/dummy/app/controllers/pets_controller.rb
155
+ - spec/fixtures/dummy/app/serializers/pet_body.rb
155
156
  - spec/fixtures/dummy/config/application.rb
156
157
  - spec/fixtures/dummy/config/environments/development.rb
157
158
  - spec/fixtures/dummy/config/routes.rb
@@ -188,6 +189,7 @@ test_files:
188
189
  - spec/fixtures/dummy/app/controllers/admin/pets_controller.rb
189
190
  - spec/fixtures/dummy/app/controllers/application_controller.rb
190
191
  - spec/fixtures/dummy/app/controllers/pets_controller.rb
192
+ - spec/fixtures/dummy/app/serializers/pet_body.rb
191
193
  - spec/fixtures/dummy/config/application.rb
192
194
  - spec/fixtures/dummy/config/environments/development.rb
193
195
  - spec/fixtures/dummy/config/routes.rb