Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Commit c27b788

Browse files
authored
Body parameters are required. (#179)
If a method takes a request body, you can't omit that; it's effectively required. We should mark it as such so swagger-codegen will generate code properly. Fixes #173.
1 parent 8abe030 commit c27b788

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

endpoints/openapi_generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ def __body_parameter_descriptor(self, method_id):
373373
return {
374374
'name': 'body',
375375
'in': 'body',
376+
'required': True,
376377
'schema': {
377378
'$ref': '#/definitions/{0}'.format(
378379
self.__request_schema[method_id])

test/openapi_generator_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def entries_post_audiences(self, unused_request):
172172
{
173173
'name': 'body',
174174
'in': 'body',
175+
'required': True,
175176
'schema': {
176177
'$ref': self._def_path(ALL_FIELDS)
177178
},
@@ -191,6 +192,7 @@ def entries_post_audiences(self, unused_request):
191192
{
192193
"in": "body",
193194
"name": "body",
195+
'required': True,
194196
"schema": {
195197
"$ref": "#/definitions/OpenApiGeneratorTestAllFields"
196198
}
@@ -215,6 +217,7 @@ def entries_post_audiences(self, unused_request):
215217
{
216218
"in": "body",
217219
"name": "body",
220+
'required': True,
218221
"schema": {
219222
"$ref": "#/definitions/OpenApiGeneratorTestAllFields"
220223
}
@@ -239,6 +242,7 @@ def entries_post_audiences(self, unused_request):
239242
{
240243
"in": "body",
241244
"name": "body",
245+
'required': True,
242246
"schema": {
243247
"$ref": "#/definitions/OpenApiGeneratorTestAllFields"
244248
}
@@ -581,6 +585,7 @@ def items_put_container(self, unused_request):
581585
{
582586
'name': 'body',
583587
'in': 'body',
588+
'required': True,
584589
'schema': {
585590
'$ref': self._def_path(PUT_REQUEST)
586591
}
@@ -689,6 +694,7 @@ def items_put_container(self, unused_request):
689694
{
690695
'name': 'body',
691696
'in': 'body',
697+
'required': True,
692698
'schema': {
693699
'$ref': self._def_path(
694700
PUT_REQUEST_FOR_CONTAINER)
@@ -715,6 +721,7 @@ def items_put_container(self, unused_request):
715721
{
716722
'name': 'body',
717723
'in': 'body',
724+
'required': True,
718725
'schema': {
719726
'$ref': self._def_path(
720727
PUBLISH_REQUEST_FOR_CONTAINER)
@@ -747,6 +754,7 @@ def items_put_container(self, unused_request):
747754
{
748755
'name': 'body',
749756
'in': 'body',
757+
'required': True,
750758
'schema': {
751759
'$ref': self._def_path(ITEMS_PUT_REQUEST)
752760
},
@@ -772,6 +780,7 @@ def items_put_container(self, unused_request):
772780
{
773781
'name': 'body',
774782
'in': 'body',
783+
'required': True,
775784
'schema': {
776785
'$ref': self._def_path(ENTRY_PUBLISH_REQUEST)
777786
},
@@ -802,6 +811,7 @@ def items_put_container(self, unused_request):
802811
{
803812
'name': 'body',
804813
'in': 'body',
814+
'required': True,
805815
'schema': {
806816
'$ref': self._def_path(ALL_FIELDS)
807817
},
@@ -821,6 +831,7 @@ def items_put_container(self, unused_request):
821831
{
822832
'name': 'body',
823833
'in': 'body',
834+
'required': True,
824835
'schema': {
825836
'$ref': self._def_path(ALL_FIELDS)
826837
},
@@ -1563,6 +1574,7 @@ def toplevel(self, unused_request):
15631574
{
15641575
'name': 'body',
15651576
'in': 'body',
1577+
'required': True,
15661578
'schema': {
15671579
'$ref': self._def_path(ID_FIELD)
15681580
},
@@ -1647,6 +1659,7 @@ def toplevel(self, unused_request):
16471659
{
16481660
'name': 'body',
16491661
'in': 'body',
1662+
'required': True,
16501663
'schema': {
16511664
'$ref': self._def_path(ID_REPEATED_FIELD)
16521665
}
@@ -1734,6 +1747,7 @@ def toplevel(self, unused_request):
17341747
{
17351748
'name': 'body',
17361749
'in': 'body',
1750+
'required': True,
17371751
'schema': {
17381752
'$ref': self._def_path(NESTED_REPEATED_MESSAGE)
17391753
}
@@ -1899,6 +1913,7 @@ def entries_post_audience(self, unused_request):
18991913
{
19001914
'name': 'body',
19011915
'in': 'body',
1916+
'required': True,
19021917
'schema': {
19031918
'$ref': self._def_path(ALL_FIELDS)
19041919
},
@@ -1923,6 +1938,7 @@ def entries_post_audience(self, unused_request):
19231938
{
19241939
"in": "body",
19251940
"name": "body",
1941+
'required': True,
19261942
"schema": {
19271943
"$ref": "#/definitions/OpenApiGeneratorTestAllFields"
19281944
}

0 commit comments

Comments
 (0)