Postman Validation and Documentation Problems - json

I am having trouble to understand how I should use postman. I am trying to write a schema to validate my test collection. Doing this I ran into a few problems:
Name/Description validation: In our test collection we have several requests to the same path, with different names. For example we have the path {{baseUrl}}/user/{id}. With this path we can create(POST) several types of users. Each request needs to be tested and has its own name (create childUser, create parentUser, create masterUser, etc).
The problem now is, when validating with the schema we get issues for every request name and description. When I remove the name from the schema, it takes the path as name which also shows issues when validating.
I think I am using it wrong. How can I identify each test request uniquely without destroying the validation?
Also when validating my API under "Test" I get "Issues found" but when I click on it the list is empty.. This is very confusing.
How do you use schema validation properly with a big test collection?
Also, the schema documentation is not generating properly and is not showing any errors. It just generates the title and server list. Any clue anyone? Also when I don't add a Collection Documentation it doesn't even show up.
Thanks in advance
John

Related

Issue with JSON and Flutter

First off, let me apologise for any mistakes, as this is my first post.
Now, for the actual issue:
I've coded a PHP script that handles MySQL Queries, including one that fetches all data from a certain table.
I made it so the final result is a JSON object, containing all rows from said table.
I also coded a Flutter class (Dart) that handles the request for the JSON object via the URL, and I got it to successfully log said JSON to the console.
However, when I use that data to show on an actual List of Widgets, this is what appears on screen:
Error Shown
Any ideas on how to fix this?
(For NDA reasons, I am not allowed to show the console logs.).
Any help is appreciated!

JSON object losing info between API call and Frontend

I'm making a website that gets its info from a RESTapi I've written and hosted myself, have had no data problems thus far.
Now I'm trying a simple retrieve of a json object and I get all the info correctly as shown here in the API. (Visualized & tested in Swagger)
As you can clearly see, it retrieves it the complete object and underlying objects correctly (blurred sensitive info).
Pay attention to the property "AmountOfEggs" though.
Now when i call this api endpoint (exactly the same way) in my site and console.log the result.data, this is the feedback.
Now for some reason I can't recieve AmountOfEggs in my frontend.
I've recreated the entire object, wrote different names, passed different props (Id, NumberBus, etc are passed in this situation with no problem, which are also int (number) types).
I have no idea why this property gets "dropped" in the transfer and filled with/defaults to an empty string.
Any help would be greatly appreciated.
I found where it went wrong and it's due to different factors.
To start, I am making this site using the Vue framework, which has reactive components, which means, data gets adjusted and you get live updated components on your views/pages.
In the page that contained the call, I also wanted to add dynamic styling. The code I used for this is the following:
v-for="seller in retrievedSellers"
:key="seller.Id"
:class="[
'sellerStyle'
, (seller.AmountOfEggs = 0 ? 'grey-out-seller' : ''),
]"
Now two things to note, first of all this might look like backend coding but this is Vue logic on the .vue file which handles the dynamic options that Vue provides so I never thought to look here for the error.
The error of couse is the 'seller.AmountOfEggs = 0' part, using one equal sign (assignment) instead of two (comparison).
So I learned,
Vue doesn't throw errors on assignments in code that is used to generate frontend (where you should NEVER alter your data).
My console.log was the moment the response of the API came in, where apparently it was already assigned a new value (due to my code above) before hitting the console.log.
It still greatly surprises me that Vue handles ^this^ first to make sure your reactive components are up to date before finishing the api call itself.
However, I still don't understand how it said "" instead of 0.
I'm using typescript (javascript strongly-typed) so it definitely wants to contain a number and not an empty string. Even in the declaration of my DTO the property is defined as (and expects) a number.

Ember Data does not recognise ID in JSON response (inheritance-related)

I've been trying to figure this out for the past couple of hours and I thought it might be best to ask for some help at this point.
I am creating a new record (e.g., a new ProducerObjectiveOutcome record). The following error is being thrown after my Ember app posts data from a form to my Rails API:
Assertion Failed: Your outcome record was saved to the server, but the response does not have an id and no id has been set client side. Records must have ids. Please update the server response to provide an id in the response or generate the id on the client side either before saving the record or while normalizing the response.
What's strange is that my API is returning a JSON response with an ID (see below).
{
"producer_objective_outcome": {
"id":27,
"type":"ProducerObjectiveOutcome",
"title":"New outcome",
"owner": {
"id":6
}
}
}
As you might already have picked up, ProducerObjectiveOutcome is a subclass of Outcome.
In both my Ember App and Rails API, I have setup ProducerObjectiveOutcome to inherit from Outcome. In my Ember App particular, this is what the model looks like:
// app/models/producer-objective-outcome.js
import Outcome from "./outcome";
export default Outcome.extend({
});
Nothing fancy going on here – I thought it was all pretty straight forward – but for some reason, that error is coming up. I'm hoping one of you marvelous people can help me out with this!
Thanks in advance!
For anyone who is interested, I solved this by changing the name of the root node of the JSON response to outcome instead of it being producer_objective_outcome.
What may have helped in my earlier explanation is that the ProducerObjectiveOutcome record was being created at the following route: producer/objective/:id/outcome/new.
The key part of this URI, as I have figured just out, is the .../outcome/... section. I haven't tested otherwise, but given the conventions in Ember, I suspect that if that URI was .../producer-objective-outcome/... then everything would have been hunky dory.
TL;DR: the names in your JSON payload should match the route.

Export entire Logical Data Model from GoodData

In this https://developer.gooddata.com/article/data-modeling-api there is a logical data model and its corresponding JSON. However, I can't seem to find out how to extract JSON from a logical data model via the REST API. Is there a way to do this other than using the single load interface (which would be very inefficient)?
For the record, my end goal is to make a tool that extracts that JSON (which would be in dev), then post that to the ldm manager2, and then apply the suggested changes through the returned MaQL to production. Any help is greatly appreciated
Currently this works only for Getting or Updating the entire Project. Anyway you can GET all model definition by simple API call. See the documentation:
http://docs.gooddatadrafts.apiary.io/
There is a GET request which is asynchronous. You can build some logic on the top of that on your end. You can get all models, store per datasets information, but at the end you need to POST the "final version" and all updates will be applied.
Let me know if I can help you with anything!
Regards,
JT

bindingResult.getAllErrors() vs bindingResult.getFieldErrors()

I am developing a application using Spring MVC 3.0 frame work, I have following requirement,
There are multiple form in one jsp page. I am using ajax to submit each form. But after submitting, each form will go to different controller. In controller I will validate input data if there is any error I need to send validation result back to jsp page. Right now I am storing errors into a separate list and sending back to jsp through json response. I am not sure whether to use bindingResult.getAllErrors() or bindingResult.getFieldErrors() to get list of errors in my controller. What's the difference between both?
getAllErrors()
By using bindingResult.getAllErrors you will get all errors, both
global and field ones.
getFieldErrors()
By using bindingResult.getFieldErrors() you will get all errors associated with the given field.
Here is a useful Link that may help you understand difference between each better.
getAllErrors() returns all errors, both Global and Field. getFieldErrors() only returns errors related to binding field values. I am not sure what a "Global" error is generated from, as I have never seen one.