In swagger post parameters on registration - swagger

With api 3 version I want to make register enntry, with most common fields :
name, email, password, password_confirmation
I needs somewhow to describe POST parameters, looks like that is not parameters?
I tried to make as :
/register:
post:
tags:
- user account
summary: Register user
operationId: postRegister
# parameters:
responses:
'200':
description: Successful registration
content:
application/json:
'400':
description: Invalid register data
1) How can I describe POST parameters ?
2) I checking http://petstore.swagger.io/ examples and I do not see any Register/login functionality.
Are there some other examples Register/login functionality?
Thanks!

Related

How to test devise API through Postman?

I am new to Rails and have setup devise with a User model with email and password with also a React frontend. My aim is to consume the signup/signin endpoints in a React app instead of using the default Rails view. When I go to http://localhost:3000/users/sign_up I can create an account and also see the data in PGadmin. However, I want to create a React based view for the forms and use the endpoint of the devise. I am trying to test the signup api using Postman but gives me an error 422 Unprocessable entity. Not sure what params to pass in Rails.
http://localhost:3000/users/sign_up
Used:
{
"user": {
"email": "test2#test.com",
"password": "test"
}
}
and
{
"email": "test2#test.com",
"password": "test"
}
First, you are in developement mode, so turn off the token authenticity (and turn on again if on product mode) for Postman requests, by add to app/controllers/application_controller.rb:
class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session
end
Then, config Postman like this:
Type of request = POST
Url = http://127.0.0.1:3000/users
Body with form-data, with after keys, values
Key: user[email]. Value: test2#gmail.com
Key: user[password]. Value: secret
Key: user[password_confirmation]. Value: secret
Click on Send button you will bypass register page and get desire results (such as new user registration informations from Postgres if you not set the Confirmation mode in Devise User)!
Go on!

SAPUI5 & ODataModel V2: Find out which request groups have pending requests

I'm using ODataModel V2 and have 3 deferred request groups. If there are requests for more than one group I have to submit them in specific order.
Therefore I need to know which group has pending requests. Is there already a smart method for?
Definition of my request groups
Entry creations via Method "createEntry" are collected into group "create"
Entry deletions via Method "remove" are collected into group "delete"
Everything else is collected into group "changes"
What I've found out so far
The "delete" group is easy, if there is one, it's contained in "oDataModel.mDeferredRequests".
The "create" group is only contained in "mDeferredRequests" if there are also requests for the "changes" group. So if it's contained in "mDeferredRequests" I know that there are requests for both "create" and "changes".
But if there are only requests for either "create" or "changes" I've found only the way via method "getPendingChanges".
The newly created entities have the groupId included within the metadata like so:
NewObject('id-123456-00'):
Attribute: "123"
__metadata:
created:
changeSetId: "chgSet"
eTag: undefined
error: undefined
groupId: "create"
...
type: "..."
uri: "/sap/opu/odata/sap/..."
The changed entities have no groupId, they look like so:
UpdatedObject(Key='123'):
Attribute: "abc"
__metadata:
id: ".../sap/opu/odata/sap/..."
type: "..."
uri: ".../sap/opu/odata/sap/..."
So my only idea at the moment is to loop over the entries from "getPendingChanges" and check if there's a groupId or not.
As I'm not happy with this solution I'd like to ask you if there's a smarter way to determine the groups with pending requests.

Cucumber Issue - POST request to create a new object

I was wondering if anyone here can please help me with this cucumber dilemma.
I'm trying to create a new object from cucumber and, as explain here, I created my post request follwing the same guidelines:
visit "/users", :post, display_name: "test", email: "test#gmail.com", password: "12345678", password_confirmation: "12345678" .
Nonetheless, I get this error when I run my test : wrong number of arguments (given 3, expected 1) (ArgumentError).
Does any of you have an idea on how to perfom this request correctly.
Thanks in advance
The answer referenced is 10 years old and the second method parameter to visit was actually removed for a very good reason.
A cucumber or feature spec is a high level test that tests the application through the user story. Users don't use cURL and send post requests straight to your application. They fill out forms and submit them to your application. If you want to test that write steps that actually fill in the form and click the submit button.
If your test just relies on a user being present in the database you should NOT need to do a POST request with page.driver.post which is ridiculously hacky. Use a fixture or a factory to setup the test instead.

RSpec / FactoryGirl - How to pass params in post request spec

I have a Rails API backend set up with restful routes. I'm trying to pass in parameters for a post request spec, but I've run into some troubles.
In my app a user has many timelines, and a timeline has many entries.
I can correctly create a timeline with a post request by doing the following:
post '/timelines', '{ "timeline": { "title":"My timeline", "body":"My timeline body"}}', #token_header
The problem i have is when i have to pass more than just string, i.e. an image. My entry model has an image attribute, but I can't figure out how to pass in into the parameters.
I have the following test which illustrates what i want to do. As you can see I've declared some entry_attributes but I can't figure out how to correctly pass them as I did with the timeline params.:
context 'POST /timelines/:id/entries' do
it 'creates an entry for the given timeline' do
entry_attr = FactoryGirl.attributes_for(:entry)
post "/timelines/#{#timeline.id}/entries", {}, #token_header
expect(response.status).to eq 201
end
end
Any help is greatly appreciated...

How do I map an application/json POST request to the params in rails?

I am being passed in a json body for a post request, but i'm not sure the best way to map this json body to request params in rails:
{
username: "example-user",
password: "password",
email: "example#gmail.com",
}
and in the controller i wish to acccess params["username"],
is this possible? how should i do it?
see the guides for a comprehensive information.
you can simply access to params[:username] or even params['username'] since params is a HashWithIndifferentAccess.
Note that you can easily inspect the params using the debugger gem, or just slam a raise in your controller action to see them on the error page when in development mode.

Resources