Skip to content

Invalid Swagger Schema - Delete #711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lstanden opened this issue Sep 27, 2018 · 4 comments
Open

Invalid Swagger Schema - Delete #711

lstanden opened this issue Sep 27, 2018 · 4 comments

Comments

@lstanden
Copy link

The following example method creates an invalid schema:

params do
  options :test_ids, type: Array[String], documentation: { param_type: 'body' }
  options :rest_ids, type: Array[String], documentation: { param_type: 'body' }
end
delete do
  # ...
end
@lstanden
Copy link
Author

lstanden commented Sep 27, 2018

The schema contains multiple in: "body" records, which is invalid for the swagger schema. It should have been extracted out to a ref.

@lstanden
Copy link
Author

lstanden commented Sep 28, 2018

I added the following monkey patch to my app, and it appears to resolve the invalid schema issues. It seems the logic is simply flawed in these existing methods:

module GrapeSwagger
  module DocMethods
    class MoveParams
      class << self
        def can_be_moved?(params, http_verb)
          includes_body_param?(params)
        end

        def should_expose_as_array?(params)
          false
        end

        def should_correct_array?(param)
          false
        end
      end
    end
  end
end

@darren987469
Copy link
Contributor

@lstanden The multiple in: 'body' are combined in GrapeSwagger::DocMethods::MoveParams , which not support delete method.

def move_methods
[:post, :put, :patch, 'POST', 'PUT', 'PATCH']
end

@lstanden
Copy link
Author

lstanden commented Oct 1, 2018

Yes, I'm aware of this @darren987469 ... by not having DELETE included, it is generating invalid swagger schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants