swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.03k stars 6.03k forks source link

[Question] Body (model) parameter should be required? #653

Closed wing328 closed 9 years ago

wing328 commented 9 years ago

In the Petstore example, the operation addPet has a body parameter, which refers to the Pet model: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.json#L43

The body field is marked as optional (required=false).

My questions is that should the body field for this particular example set to required?

Currently the ruby code looks like this: add_pet(:body => pet)

Ideally it should look like add_pet(pet)

webron commented 9 years ago

It should probably be required in this specific use case. Please open an issue on swagger-core for that and we'll fix it.

wing328 commented 9 years ago

Opened swagger-api/swagger-core#990