I'm doing mi Swagger and in one endPoint y COULD receive a boolean parameter, if i dont get the parameter its fine.
When i receive the parameter and its true it will do a special filter. The question is, can i tell to Swagger the option its optional and if the client choose to select a option it will be only true?
As you can see the "OnlyActive" is optional, thats good, now i need that the posibles option only be
"--"
"true"
and nothing more
This is the fragment of code
Lane 20
thank u a lot
Related
I would like to do a DELETE request with unspecified number of parameters a=someValue. There is 2 main ways of supplying parameters to my understanding
Query parameters. ?a=someValue . This approach turn everything into
string and since I allow any number of parameters, I cannot know
which one is String, Boolean or Integer
Parameters in Body.This approach goes against the spec of DELETE operation to not have a body. Some server even strip away the body-content. But as I
send an json object, user can specify which type of value each of
their parameters has.
What would be your approach for this?
I'd use query parameters over body as the DELETE method has an optional body. Some clients may choose to ignore the body totally.
I'm trying to practice defensive programming. Following the advice from the documentation, I want to poll using the api passing in a value 3 minutes before the last time I polled. Considering, I could get a ResultSetSize less than the TotalSetSize, I'd like to ask for the next set of results starting at the next result.
So, as an example, I request the following (using the REST API explorer):
GET https://demo.docusign.net/restapi/v2/accounts/#####/envelopes?count=2&from_date=2017-01-01&from_to_status=changed HTTP/1.1
(note the count = 2)
This returns:
Object
resultSetSize: "2"
totalSetSize: "8"
startPosition: "0"
endPosition: "1"
nextUri: "/accounts/#####/envelopes?start_position=2&count=2&from_date=1%2f1%2f2017+12%3a00%3a00+AM&from_to_status=changed"
previousUri: ""
envelopes: Array [2]
Ok, great, exactly as I expect. Now, I want to get the second "page" of results. I add a start_position of 2, right? (Since the end position is 1, I'd expect to get startPosition 2 and endPosition 3 to be returned.)
GET https://demo.docusign.net/restapi/v2/accounts/#####/envelopes?count=2&from_date=2017-01-01&from_to_status=changed&start_position=2 HTTP/1.1
No dice... 400 Bad Request:
Object
errorCode: "INVALID_REQUEST_PARAMETER"
message: "The request contained at least one invalid parameter. Query parameter 'count' was not a positive integer."
The count parameter is a positive integer...
Please, someone tell me what I'm doing wrong. I would like to just request as many as they can pass at a time, and if there are more, I'd like to repeat until all envelopes have been retrieved, but that "count" error is concerning.
From documentation
start_position parameter is reserved for DocuSign use only.
Looks like pagination is not supported with the listStatusChanges api.
If you call the nextUri address, what happens? You will need to prepend your base URL.
My code is like below:
server.get('/currency/:code', currency.find);
server.get('/currency/rates', currency.rate_getall);
Whenever I try to reach [/rates] endpoint, the server will assume I am passing parameter to '/currency/:code' route. How can I fix this? Thank you.
Ryan
If you can I would consider changing up your rest interface just a little.
server.get('/currency/:code', currency.find);
server.get('/currency/rates/:type', currency.rate);
That way it solves your initial problem and allows for flexibility in the future if you just want to return a rate for a particular currency.
Inside your currency.rate function you could check for either an id or the literal 'all' and return what is appropriate.
I've created a Swagger (on nodejs/express) test API with this specification (only relevant part):
...
parameters:
- name: name
in: query
required: true
type: string
...
But I can call the url with empty paramter, for example
http://localhost/test?name=
And it works without any problem, throws no exception or any other sign. Why?
If I make a similar call from the terminal via curl or via postman, it works as well. I parsed the query from the request object and found that in this case, the query parameter is interpreted as an empty string.
Making the call via SwaggerUI is different though, as the UI will actually not make the call UNLESS the query field has a value.
Try doing console.log(req.query); in your handler. You will probably see {name: ''}. Which is legitimate, just that the value of name is an empty string.
Look at JSON4 here: Representing null in JSON. So name IS defined, but it's empty.
You will probably need to do a check for empty string values.
I hope this helps!
Is it possible to specify some kind of "OR" (alternative) clause in Cucumber?
I.e. if I have two valid responses to some event I would like my test to pass if either of them happens.
Something like that:
"When I press a button"
"Then I should see the text 'Boo'"
"Or I should see the text 'Foo'"
My particular scenario is a login screen. When I try to log in with some random password, I should see an error message "invalid password" if the server is working or a message "network error" if it is not.
You can't really define OR functionality using the Gherkin but you can pass in a list and check that one of the values in the list matches what was returned.
Define list:
Then the greeting service response will contain one of the following messages
|Hello how are you doing?|
|Welcome to the front door!|
|How has your day been?|
|Come right on in!|
Check list:
#Then("the get messages service response will contain one of the following messages")
public void text_matching_one_of_the_following(List<String> greetingMessages){
boolean success = false;
for(String message : greetingMessages){
assertTrue(textMatchesResponse(message));
}
}
OR is not supported. You can use Given, When, Then, And and But. Please refer to http://docs.behat.org/en/v2.5/guides/1.gherkin.html
But perhaps you could make use of the But keyword to achieve what you are looking for.