Trying to use external reference in Postman with tv4 - validation

I'm trying to use an external reference in Postman and validating that with tv4.
This is my code:
var schema = tv4.getSchema('https://schema.getpostman.com/json/collection/v1/');
console.log(tv4.validate(responseBody, schema);
and after testing I get
'TypeError Cannot read property '$ref' of undefined'
.
Does that mean my schema is not valid somehow?

I know it's late, but this could help others
tv4.getSchema(name) is used to retrieve an already loaded schema. tv4.addSchema(name, schema) is used to append a new schema of name with schema value
So, what should you do?
Reading this article I understood that you can't make two requests in a test using Postman. Instead you should store its value in a environment or global variable and don't use tv4's functions as those (I guess) were meant to be used in environments where you can actually download a schema using http module.
Finally, your example should look as this
var schema = JSON.parse(postman.getEnvironmentVariable('myEnvVarName'));
let valid = tv4.validate(pm.response.json(), schema, false, true);

Related

FHIR Observation DSTU2 resource

I need some help getting the value and unit of a result from the FHIR Observation DSTU2 resource. I want to map these values to strings but it looks like Observation.value[x] can have different type of data. Any thoughts on how to do this in C#? I tried a few ways but no luck so far because the sandbox I'm using contains results as strings, Quantity and CodeableConcept.
http://hl7.org/fhir/observation-definitions.html#Observation.value_x_
For the Observation.value field you indeed have a choice of type, so the data in the FHIR resource can hold any of the choices listed for that field.
If you use the Hl7.Fhir.Dstu2 library - the official C# reference implementation available through NuGet, you can use it to easily retrieve the resources from your sandbox and get them into a POCO. Here's an example:
using Hl7.Fhir.Model;
using Hl7.Fhir.Rest;
var client = new FhirClient("<your sandbox url>");
var obs = client.Read<Observation>("Observation/<technical id>");
// now you can access obs.Value regardless of the type in it
if you need to serialize the data to xml or json, you use the serializer:
using Hl7.Fhir.Serialization;
var serializer = new FhirJsonSerializer();
Console.WriteLine(serializer.SerializeToString(obs));

How can I have custom identifiers/primary keys for my resources?

My table has a primary key other than id and react-admin enforces id to be returned in the response by the DataProvider. So can I configure different primary keys/identifiers for my resources?
I am using this library - https://github.com/Steams/ra-data-hasura-graphql
Right now I have made few changes in my library code to make this work, but I need an idea to implement it, so anyone using this library doesn't need to go thru whole code to make it work.
const config = {
'primaryKey': {
'tableName': 'primaryKey1', 'tableName2': 'primaryKey2'
}
};
I was thinking of something like passing configuration like this.
Thanks.
I don't believe it is currently possible with the 0.1.0 release. However in hasura you can expose the column with a different name
hasura column exposed name

GraphQL Nexus - adding custom scalar type

GraphQL Nexus is fairly new and the documentation appears to be lacking. In addition the examples are lacking as well. From the example and from the doc I am trying to add my own NON-GraphQL scalar type. I created my own scalar following the example in the documentation however when I try to call it in an objecttype I get the read underline. What am I doing wrong?
To resolve this issue what I did was:
1. once you create your own scalar type such as:
#json.ts **FILE NAME MATTERS**
export const JSONScalar = scalarType({
name: "JSON",
asNexusMethod: "json",
description: "JSON scalar type",
...})
2. Once I called the new type in a separate object I had to add this above my field for it to compile, you may not have too:
//#ts-ignore
t.topjson("data");
3. In my make schema I added the scalar code first:
const schema = makeSchema({
types: [JSONScalar, MyObject, BlahObject],
The name of the file is very important I think that is how the schema is generated and looks for the new type. I also think you have to be sure to compile that code first in the makeSchema however I did not try to switch around the order as I spent a lot of time trying to figure out how to make my own scalar type work.
This may have been self explanatory for more seasoned Nexus developers however I am a novice so these steps escaped me.
Happy coding!
You can also do this:
t.field("data", {type: "JSON"});
That works perfectly fine with TypeScript.
And I wish they had better examples and documentation. Their examples only cover the most trivial use cases. I'm getting very heavily into GraphQL, Prisma, Nexus and related tool for a huge data set. So I'm literally hitting every limitation and lack of documentation that exists.
But alas we can pool our knowledge here.

Can't get the language entity with the method _languageRepository.FirstOrDefault(x=>x.Name=langCode)

Please help me solve this issue ,it drivers me mad .Thank you in advance.
Version:3.1.3 Abp ModuelZero MPA
I need to get the language id by language name from Database.
So I inject the Repository as below.
private readonly IRepository<ApplicationLanguage> _languageRepository;
Then I use the below method to get the language entity
var lang = _languageRepository.FirstOrDefault(x=>x.Name==langName);
but the result is null .The parameter is 'zh-TW' and I am sure it exists in database.
The below screenshots for your reference.
var lang = _languageRepository.Where(x=>x.Equals(langName)).FirstOrDefault();
return lang?.Id;
lang?.Id is to handle null.

Codeigniter, uri->segment, str_len

I'm very new to php and mysql. I'm trying to pass the value "part(2)" to my code igniter controller. "part(2)" is one of the name of the data values in my database. After passing it to the uri segment, I extracted it using the command $value = str_replace("%20", " ", $this->uri->segment(5)); . Now when i search my database using the variable $value, it's not displaying the results. I presume the problem is with having using "()". I am wondering if it has anything to do with the data type utl8 vs latin1. My database is configured to use latin1_general_ci. I have tried changing the database field type to utl8_general_ci, but it does not work. Can anyone please help me out here?.
Have you tried var_dump($value) just to see what it contains?
Also, the result from $this->db->last_query(); might be useful to see what you are actually quering your database for. I don't see a reason why you couldn't put perenthesis in your database.
Im pretty sure both utf8 and latin1 are fine.
can you post your controller code?
firstly, if you are passing the value in your uri, do you have () in your permitted uri characters in application/config/config.php?
something like this:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-()';
But I just tried this and my values came out with html entities: part(2) instead..
you can fix this with something like this:
input_value = html_entity_decode($input_value);

Resources