grape

How to import the jenkins-api in Groovy?

天大地大妈咪最大 提交于 2019-12-31 02:32:06
问题 I have a small groovy script that I want to edit and I have issues with the dependency management in Groovy. I am new to groovy and sorry in advance if this question is kinda studip / easy to answer. I use IntelliJ as IDEA. @Grab(group='org.jenkins-ci.main', module='jenkins-core', version='2.167', scope='provided') //import jenkins... def call() { Jenkins.instance.getItemByFullName(currentBuild.fullProjectName).getBuilds().each{ build -> if (currentBuild.number > build.number && exec != null)

User Authentication with Grape and Devise

做~自己de王妃 提交于 2019-12-29 02:48:09
问题 I have difficulties to understand and also properly implement User Authentication in APIs. In other words, I have serious problem to understand the integration of Grape API with front-end frameworks such as Backbone.js, AngularJS or Ember.js. I'm trying to pivot all different approaches and read a lot about that, but Google returns me truly bad resources and it seems to me, like there is no really good article on this topic - Rails and User authentication with Devise and front-end frameworks

Add custom response header with Rack-cors and Grape

血红的双手。 提交于 2019-12-25 07:03:04
问题 I'm developing a Ionic(Cordova) app with a Ruby on Rails API. I want to use response headers to return a token after login. I'm using rack-cors gem to make Cross Origin Request work: application.rb config.middleware.insert_after Rails::Rack::Logger, Rack::Cors, :logger => Rails.logger do allow do origins '*' resource '/api/*', :headers => :any, :methods => [:get, :post, :options, :put] end end and grape gem to manage my API routes. But i can't find a way to add a header to my response since i

grape api ignores PUT/POST params

微笑、不失礼 提交于 2019-12-25 00:58:25
问题 I am building a grape api for a rails app. I am testing it with rspec request specs. I have encountered the problem when making a post route like this: resources :events do segment '/:event_id' do resources :tickets do post do event = current_user.events.find params[:event_id] ...#do sth with event using params[:tickets_ids] the corresponding spec: it "should should return the JSON hash of validated tickets" do post "/api/mobile/#{version}/events/#{event.id}/tickets/", { tickets_ids: [1,2] },

Which Jersey version runs in Jenkins 2.107.1?

扶醉桌前 提交于 2019-12-24 19:02:07
问题 We are running a Jenkins on Ubuntu. When we try to use a Java library in a Pipeline that uses REST calls, we run into problems. UriBuilder is apparently used in a old version: The method toTemplate is missing and caused a MethodNotFound. This is strange because the Java library depends transitively on <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <version>2.0.1</version> which contains the new version of UriBuilder. We used Grape and correctly copied the library with

Groovy Grape dealing with dependency resolution

旧时模样 提交于 2019-12-23 20:09:13
问题 I am trying to use org.xhtmlrenderer:core-renderer:R8pre2 in a groovy script, but I get a Linkage error: Caught: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.xerces.dom.NodeImpl.getOwnerDocument()Lorg/w3c/dom/Document;" the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of <bootloader>) for interface org/w3c/dom/Node

Why does mounting a route in Rails fail with “uninitialized constant API”?

心已入冬 提交于 2019-12-22 06:56:46
问题 I am working on an app that includes an API that is using the grape gem. Here is my Root Class: module API class Root < Grape::API rescue_from :all do |e| Rack::Response.new( [ "Error: #{e.message}" ], 500, { "Content-type" => "text/error" } ).finish end prefix "api" version 'v1', using: :path format :json error_format :json mount ::API::ServiceRequests end end Here is how I am mounting it in routes: mount API::Root => '/' The error I am receiving is: routes.rb:45:in block in ': uninitialized

How to validate this hash parameter?

本秂侑毒 提交于 2019-12-21 05:16:20
问题 How do I write the correct params validations for this hash parameter: { "files": { "main.c": { "contents": "#include <stdio.h> ...", "foo": "bar" }, "main.h": { "contents": "#define BLAH ...", "foo": "baz" }, ... more files here ... } } files is the hash parameter that I want to validate. Each key of files can be anything (a string); the values are hashes with a specific format that also needs to be validated (requires contents and foo ). I'm using grape 0.9.0. This is kind of what I want to

How to create two routes in one block in grape?

与世无争的帅哥 提交于 2019-12-19 11:30:06
问题 I want to catch 2 similar route in one action block. In Rails5 I can do that easily. I first declare this: get ':folder/:file' => 'get#index', :file => /.*/, :folder => /.*/ get ':file' => 'get#index', :file => /.*/ This allows me to catch :folder as much as folder can be like a/b/c/d... and :file at end one last filename. Second one also allow me to only catch filenames. And both routes target to same action. However, In Grape because it is declared as blocks rather than route to method

Wildcard route in Grape

孤街醉人 提交于 2019-12-13 15:26:57
问题 I'm having issues getting Grape to respond to a purely wild card route. By that I mean that if I have a simple route defined as get do ... end I need to respond to all potential requests made to the API. The situation being I need to parse the path and params and then work through a decision tree based on those values. I've tried a few variations on the route definition, such as: get '/*' do ... end get '/(*)' do ... end But to no avail. I know that there is some support for regular