I am new in JSON schema and trying to validate my request with JSON schema. So i created schema. But i don't know why i am not able to give refrence to any another schema which located in same folder can any one help me to how to give $ref
{
"$id":"file:/schemas/ActionType",
"title":"ActionType",
"type":"object",
"properties":{
"ActionType":{
"enum":["fullLoad","update","insert","delete"]
}
},
"additionalProperties": false,
"required": ["ActionType"]
}
{
"$id":"file:/schemas/ERoaming",
"title":"ERoaming",
"type":"object",
"properties":{
"ActionType":{
"type":"object",
"$ref":"/schemas/ActionType.json"
}
},
"additionalProperties": false,
"required": ["ActionType"],
"$defs": {
}
}
I tried with without $id, relative path, path.
First of all, I don't think that's a valid file URI. It should look like file:///path/to/schemas/ActionType with three /s after the : and the full system path. You can't use a relative path.
Otherwise, everything looks fine with the schema. Another likely problem is that not all JSON Schema libraries understand files that reference the file system. You'll want to make sure the one you're using supports that feature.
When you're working with schemas in files, it's unnecessary to use $id. If the library properly handles file system references, the full path and filename should be automatically be used as the schema identifier. Then you can use relative references like I'm sure you're familiar with, { "$ref": "./ActionType.json" }.
Related
We get an error on deploying our Logic-App with Azure DevOps.
I can't explain why this error occurs all at once.
Has anyone seen this error message before?
InvalidRequestContent:
Request content contains one or more instances of unsupported reference property names ($id, $ref, $values) creating ambiguity in paths 'properties.definition.actions.Parse_JSON.inputs.schema.properties.caseId.$ref,properties.definition.actions.Parse_JSON.inputs.schema.properties.integrationId.$ref'.
Please remove the use of reference property names and try again.
Our logic-app contains following JSON-Parse code. Apparently the variable "#/definitions/nonEmptyString" is defined twice.
"caseId": {
"$ref": "#/definitions/nonEmptyString",
"type": "string"
},
Issue reproduced from my end and got expected results.
The issue is with $ref which is not supported by Azure logicapps as mentioned in error got.
Created logic app as shown below and the sample JSON-Parse code is taken as per your requirement
{
"caseId": {
"$ref": "#/definitions/nonEmptyString",
"type": "string"
}
}
By taking $ref got the same error as shown below
Failed to save logic app parselp. Request content contains one or more instances of unsupported reference property names ($id, $ref, $values) creating ambiguity in paths 'properties.definition.actions.Parse_JSON.inputs.schema.caseId.$ref'. Please remove the use of reference property names and try again.
Then removed $ and taken ref in Parse Json as shown and logic App saved successfully without that error and workflow ran successfully.
I have fixed the problem by changing the following code
"definitions":{
"nonEmptyString":{
"minLength":1,
"type":"string"
}
},
"properties":{
"caseId":{
"$ref":"#/definitions/nonEmptyString",
"type":"string"
}
to this code
"properties":{
"caseId":{
"minLength":1,
"type":"string"
}
Maybe the problem was simply that my old solution defined "type": "string" twice. But I have not tested that yet.
I am currently writing a Lambda authorizer for an AWS AppSync API, however the authorization depends on the target resource being accessed.
Every resource has their own ACL listing the users and conditions for allowing access to it.
Currently the best I could find would be to get the identity of the caller, look at all the ACLs, and authorize the call while denying access to all the other resources, what's not only highly inefficient, but also extremely impractical, if not impossible.
The solution I had originally came up with was to get the target resource, retrieve the ACL and check if the user fits the specified criteria. The problem is that I am unable to reliably define what's the target resource. What I get from AWS is a request like this:
{
"authorizationToken": "ExampleAUTHtoken123123123",
"requestContext": {
"apiId": "aaaaaa123123123example123",
"accountId": "111122223333",
"requestId": "f4081827-1111-4444-5555-5cf4695f339f",
"queryString": "mutation CreateEvent {...}\n\nquery MyQuery {...}\n",
"operationName": "MyQuery",
"variables": {}
}
}
So, I only have the query string and variables, leaving the actual parsing of this to me. I got to convert it to an AST using graphql-js, but it's still extremely verbose and most importantly, it's structure varies greatly.
My first code to retrieve the target worked for the AppSync console queries, but not the Amplify Front-End, for example. I also can't rely on something as simple as the variable name, as an attacker could quite easily craft a query with an arbitrary name, or even not use variables at all.
I thought about implementing this authorization logic within Lambda Resolvers, what should be simpler in a way, but would require me to use resolvers as authorizers, what doesn't seem ideal, and implement the entire resolver logic when I just want the most trivial possible resolvers.
Ideally I'd like something like this:
/* Schema:
type Query {
operationName(key: KEY!): responseType
}*/
/* Query:
query abitraryQueryName($var1: KEY!) {
operationName(key: $var1) {
field1
field2
}
}*/
/* Variables:
{ "var1": "value1" } */
parsedQuery = {
operation: "operationName",
params: { "key": "value1" },
fields: [ "field1", "field2" ]
};
Is there any way to resolve/simplify the queries from GraphQL to JSON/similar in a way that this information can be easily extracted?
Well, couldn't find anything on it, so I made something myself.
On the off chance someone needs something similar, here's the gist with the code I used: https://gist.github.com/Iorpim/6544dad46060522dd0b17477871bc434
I didn't make it a proper full lib, as it's a very specific use case and it's likely a one-off, and I am also not sure how reliable it is, but it solves my problem!
I'm fairly new to Logic Apps and I have an app that I'm trying to get to move an email to a subfolder of the Inbox in a shared mailbox, but I'm trying to generate the path based on the date and I cannot for the life of me get it to work. I don't know if my path syntax is wrong or what.
The subfolder structure is basically
- Inbox
- 2018
- Jan
- Feb
- Mar
- Etc
And I'm trying to generate the path based off the year and the month using the Expressions part of a field. I've got an expression that generates the path for me
concat('Inbox\',formatDateTime(convertFromUtc(utcNow(),'Mountain Standard Time'),'MMM'),'\',formatDateTime(convertFromUtc(utcNow(),'Mountain Standard Time'),'yyyy'))
When the logic app runs this generates the correct path string of Inbox\2018\Jan but when the Move Email action runs it always escapes the backslash and then says it can't find the folder Inbox\\2018\\Jan.
So I either have this format wrong, I can't put the email in a subfolder or there's another way to do this.
I tried using the folder picker to pick one of the month subfolders and then peeked at the code and it uses some base64 encoded string for the path. I've pasted below what the peeked code shows
{
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/Mail/Move/#{encodeURIComponent(triggerBody()?['Id'])}",
"queries": {
"folderPath": "Id::AAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA="
},
"authentication": "#parameters('$authentication')"
},
"metadata": {
"Id::AAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA=": "Jan"
}
}
Does anyone know how I would be able to move an email to a subfolder without using the folder picker?
Edit: Since posting I've also tried using the following strings that also do not work
Inbox/2018/Jan
Inbox:/2018/Jan
/Inbox/2018/Jan
You cant really have the path in terms of a hierarchy folder structure in this particular logic app.
If you look at the Documentation for Office 365 Mail rest operations #
https://msdn.microsoft.com/office/office365/api/mail-rest-operations#MoveCopyMessages
You will notice that to Move messages what you actually need is a folder ID. Also if you look at the logic app Designer, when you select a folder directly from there and then look at the code view you will see an ID. It looks something like
"method": "post",
"path": "/Mail/Move/#{encodeURIComponent(triggerBody()?['Id'])}",
"queries": {
"folderPath": "Id::AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQBT8bGPBJK8Qqoy01hgwH4rAAEJysaQAAA="
}
},
"metadata": {
"Id::AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQBT8bGPBJK8Qqoy01hgwH4rAAEJysaQAAA=": "Jan"
},
The FolderID is unique to every folder. One easy way to find the FolderIDs for a folder is to use
https://developer.microsoft.com/en-us/graph/graph-explorer#
and after signing in , posting
https://graph.microsoft.com/beta/me/mailFolders/Inbox/childFolders
as the query which will give you the ChildFolders for Inbox the values will look something like the following for every folder
"value": [
{
"id": "AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQBT8bGPBJK8Qqoy01hgwH4rAAEJysWPAAA=",
"displayName": "AZCommunity",
"parentFolderId": "AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQDX8XL9o4tkR5vF5sEdh44eAIYnQnhhAAA=",
"childFolderCount": 0,
"unreadItemCount": 5,
"totalItemCount": 169,
"wellKnownName": null
},
For what you are trying to do, you will have to do additional work to map the folders to the folder ID and then assign using that. I would suggest using Azure Functions to easily do this.
I am developing an applications using MongoDB, Sails JS and ElasticSearch.
MongoDB is used to write records that are retrieve for the application. ElasticSearch is used for search text and geo locations distance search etc.
I am using mongo-connector to keep my data in sync from MongoDB to ElasticSearch.
Issue is, i am not able to maintain my mappings for geo_point for the fields that store lat and lon or parent/child or analyzer etc. Every time sails server is lifted i see in elasticsearch logs that all the mappings are removed, created and updated, and i lose my mapping for geo_point that is have created manually via the REST after every thing is up and running or even if i have created mapping at bootstrap time of sails js(as a work around).
I have also tried to create a mapping file and placed it in elasticsearch/config/mappings/index/mymapping.json but i get an error
Caused by: org.elasticsearch.index.mapper.MapperParsingException: Root type mapping not empty after parsing! Remaining fields: ...
Here i tried all the combinations to make this work but no success eg
{"mappings" : {
"locations" : {
"dynamic": "false",
"properties":{
"location": {
"type": "geo_point"
}
}
}
}
}
Also tried using a template to create the mapping but after that mongo-connector kick in and overrides the mapping.
As of now i am only able to make this work is to stop mongo-connector, delete the oplog.timestamp file, start the sails server(Here at bootstrap time i delete and recreate the mapping for that document) and then start mongo-connector. But this create accidents if we forgots to do a step.
Am i doing any thing wrong or is there a better way to sync the mongodb to elasticsearch without losing the custom mapping or an alternative mongo-connector.
According to the documentation, if you install a mapping on the filesystem, the file must be named <your_mapping>.json so in your case it should be named locations.json and be placed either in
elasticsearch/config/mappings/_default/locations.json
or
elasticsearch/config/mappings/<your_index_name>/locations.json
Moreover, you mapping file shouldn't contain the mappings keyword, it should instead look like this:
{
"locations" : {
"dynamic": "false",
"properties":{
"location": {
"type": "geo_point"
}
}
}
}
You should try again after correctly naming your mapping file and folders.
When I browse to a gist on gist.github.com it displays a friendly name. E.g. for
https://gist.github.com/stuartleeks/1f4e07546db69b15ade2 it shows stuartleeks/baz
This seems to be determined by the first file that it shows in the list of files for the gist, but I was wondering whether there is any way to retrieve this via the API?
Not directly, but you can get with the Gist API the JSON information associated to a gist, reusing the id of your url:
GET /gists/:id
In your case: https://api.github.com/gists/1f4e07546db69b15ade2
It includes:
"files": {
"baz": {
"filename": "baz",
and:
"owner": {
"login": "stuartleeks",
That should be enough to infer the name stuartleeks/baz.