fotinakis / swagger-blocks

Define and serve live-updating Swagger JSON for Ruby apps.
MIT License
622 stars 98 forks source link

Is it possible to declare input parameters as Objects or as an Array of objects? #102

Closed jduarte closed 7 years ago

jduarte commented 7 years ago

I am trying to declare input parameters as array of objects or even as objects but none of this seems to work:

swagger_path "/set_diet_plan" do
          operation :post do
            extend SwaggerExtensions::AuthenticationError
            extend SwaggerExtensions::ApiAuth
            extend SwaggerExtensions::UnprocessableEntityError

            key :summary, "Creates or updates the current patient diet plan"
            key :description, "Creates or updates the current patient diet plan"
            key :operationId, "setDietPlan"
            key :produces, ["application/json"]
            key :tags, ["Patients"]

            parameter do
              key :name, :physical_activity_to_add_1
              key :in, :query
              key :description, "list of physical activities that will be added to the current activity plan"
              key :type, :object
              items do
                property :teste do
                  key :type, :string
                end
                property :teste2 do
                  key :type, :string
                end
              end
            end
            # ....

OR

swagger_path "/set_diet_plan" do
          operation :post do
            extend SwaggerExtensions::AuthenticationError
            extend SwaggerExtensions::ApiAuth
            extend SwaggerExtensions::UnprocessableEntityError

            key :summary, "Creates or updates the current patient diet plan"
            key :description, "Creates or updates the current patient diet plan"
            key :operationId, "setDietPlan"
            key :produces, ["application/json"]
            key :tags, ["Patients"]

            parameter do
              key :name, :physical_activity_to_add_1
              key :in, :query
              key :description, "list of physical activities that will be added to the current activity plan"
              key :type, :array
              items do
                property :type, :object
                property :teste do
                  key :type, :string
                end
                property :teste2 do
                  key :type, :string
                end
              end
            end
            # ....

Is this supported?

fotinakis commented 7 years ago

Sorry, this is not a swagger-blocks question, this is a Swagger question. See: https://github.com/fotinakis/swagger-blocks#filing-issues for where you can get help

dduqueti commented 5 years ago

@jduarte did you find how to implement this?