Skip to content

Commit 543dba2

Browse files
authored
fix: only add mutually exclusive description if argument is a lookup argument set (#81)
* fix: only add mutually exclusive description if argument is a lookup argument set * chore: add plain_text post which does not contain the mutually exclusive description
1 parent adb3a0d commit 543dba2

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

examples/core_api/base.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Base < Apia::API
1818
add "time", "Allows time telling functions"
1919
end
2020

21-
routes do
21+
routes do # rubocop:disable Metrics/BlockLength
2222
schema
2323

2424
get "time_formatting/incredibly/super/duper/long/format", controller: Controllers::TimeController,
@@ -27,6 +27,7 @@ class Base < Apia::API
2727
post "example/format_multiple", controller: Controllers::TimeController, endpoint: :format_multiple
2828

2929
get "plain_text", endpoint: Endpoints::PlainTextEndpoint
30+
post "plain_text", endpoint: Endpoints::PlainTextEndpoint
3031

3132
get "paginated", endpoint: Endpoints::PaginatedEndpoint
3233

lib/apia/open_api/objects/schema.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ def generate_child_schemas
8080
@children = @definition.fields.values
8181
elsif @definition.type.argument_set?
8282
@children = @definition.type.klass.definition.arguments.values
83-
@schema[:description] ||=
84-
"All '#{@definition.name}[]' params are mutually exclusive, only one can be provided."
83+
if @definition.type.klass.ancestors.include?(Apia::LookupArgumentSet)
84+
@schema[:description] ||=
85+
"All '#{@definition.name}[]' params are mutually exclusive, only one can be provided."
86+
end
8587
elsif @definition.type.object?
8688
@children = @definition.type.klass.definition.fields.values
8789
elsif enum_definition?

spec/support/fixtures/openapi.json

+53
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,45 @@
308308
"$ref": "#/components/responses/APIAuthenticator403Response"
309309
}
310310
}
311+
},
312+
"post": {
313+
"operationId": "post:plain_text",
314+
"summary": "Plain Text Endpoint",
315+
"description": "Return a plain text response",
316+
"tags": [
317+
"Core"
318+
],
319+
"requestBody": {
320+
"content": {
321+
"application/json": {
322+
"schema": {
323+
"properties": {
324+
"disk_template_options": {
325+
"type": "array",
326+
"items": {
327+
"$ref": "#/components/schemas/KeyValue"
328+
}
329+
}
330+
}
331+
}
332+
}
333+
}
334+
},
335+
"responses": {
336+
"200": {
337+
"description": "Return a plain text response",
338+
"content": {
339+
"text/plain": {
340+
"schema": {
341+
"type": "string"
342+
}
343+
}
344+
}
345+
},
346+
"403": {
347+
"$ref": "#/components/responses/APIAuthenticator403Response"
348+
}
349+
}
311350
}
312351
},
313352
"/paginated": {
@@ -1098,6 +1137,20 @@
10981137
}
10991138
}
11001139
},
1140+
"KeyValue": {
1141+
"type": "object",
1142+
"properties": {
1143+
"key": {
1144+
"type": "string"
1145+
},
1146+
"value": {
1147+
"type": "string"
1148+
}
1149+
},
1150+
"required": [
1151+
"key"
1152+
]
1153+
},
11011154
"PaginationObject": {
11021155
"type": "object",
11031156
"properties": {

0 commit comments

Comments
 (0)