jsonix properties - ogc-schemas .js aren't same - jsonix

The manual on jsonix properties at https://github.com/highsource/jsonix/wiki/Properties shows properties as being something like:
name: 'MyModule',
typeInfos: [{
type: 'classInfo',
localName: 'InputType',
propertyInfos: [{
type: 'attribute',
typeInfo: 'Boolean',
name: 'checked'
}]
}],
But then (after npm install ogc-schemas) what I am seeing is:
ln: 'TimeClockPropertyType',
ps: [{
n: 'timeClock',
rq: true,
en: 'TimeClock',
ti: '.TimeClockType'
},
With the abbreviated names.
Which should it be and why doesn't it matter if it doesn't?

Disclaimer: I'm the author of jsonix.
This is what's called compact naming. This is an option of the Jsonix Schema Compiler which generates shorter names in mappings, like n instead of name or dens instead of defaultElementNamespaceURI. The goal is clearly to make mappings smaller and since ogc-schemas are pretty large, they are compiled with compact naming by default.
If you want standard naming, fork and remove
<arg>-Xjsonix-compact</arg>
from all the pom.xmls.
Both compact and standard names work in runtime, I think standard names have higher priority.

Related

eslint no-restricted-imports - prevent an import from from path ending with pattern

According to the eslint no-restricted-imports documentation
When using the object form, you can also specify an array of
gitignore-style patterns:
"no-restricted-imports": ["error", {
"paths": ["import1", "import2"],
"patterns": ["import1/private/*", "import2/*", "!import2/good"] }]
(Emphasis mine)
What I'm trying to do is restrict imports from parent index files - as this is causing issues with cyclical dependencies (I am also using the import/no-cycle rule, but it makes sense to also explicitly use this rule.)
That is, I want to ban imports like:
import foo from "../..";
import bar from "../../..";
I also want to ban imports like:
import a from "../Components";
but not like
import b from "../Components/Foo";
I have tried using this rule:
'no-restricted-imports': [
'error',
{
patterns: [
'**/..',
'**/Components'
]
},
But this causes on errors on imports of:
import b from "../Components/Foo";
Is there a way to specify 'end of string' in a gitignore style pattern?
First, make sure you don't have set import/no-relative-parent-imports, or any ../ import would fail.
Second, if this really follows .gitignore rules, you cannot have rules for folders (like **/.. or **/Components).
Because, once you ignore a folder, any other rule for elements inside that folder would be ignored.
Try:
'no-restricted-imports': [
'error',
{
patterns: [
'**/../*',
'!**/../Components',
'**/../Components/*',
'!**/../Components/Foo',
]
},

In Cloudformation YAML, use a Ref in a multiline string (? use Fn:Sub)

Imagine you have a aws resource such as
Resources:
IdentityPool:
Type: "AWS::Cognito::IdentityPool"
Properties:
IdentityPoolName: ${self:custom.appName}_${self:provider.stage}_identity
CognitoIdentityProviders:
- ClientId:
Ref: UserPoolClient
The Ref for "AWS::Cognito::IdentityPool" returns the id of this resource. Now lets say I want to reference that id in a multiline string. I've tried
Outputs:
AmplifyConfig:
Description: key/values to be passed to Amplify.configure(config);
Value: |
{
'aws_cognito_identity_pool_id': ${Ref: IdentityPool}, ##<------ Error
'aws_sign_in_enabled': 'enable',
'aws_user_pools_mfa_type': 'OFF',
}
I've also tried to use Fn:Sub but without luck.
AmplifyConfig:
Description: key/values to be passed to Amplify.configure(config);
Value:
Fn::Sub
- |
{
'aws_cognito_identity_pool_id': '${Var1Name}',
'aws_sign_in_enabled': 'enable',
}
- Var1Name:
Ref: IdentityPool
Any way to do this?
Using a pipe symbol | in YAML turns all of the following indented lines into a multi-line string.
A pipe, combined with !Sub will let you use:
your resources Ref return value easily like ${YourResource}
their Fn::GetAtt return values with just a period ${YourResource.TheAttribute}
any Pseudo Parameter just as is like ${AWS:region}
As easy as !Sub |, jumping to the next line and adding proper indentation. Example:
Resources:
YourUserPool:
Type: AWS::Cognito::UserPool
Properties:
UserPoolName: blabla
Outputs:
AmplifyConfig:
Description: key/values to be passed to Amplify.configure(config);
Value: !Sub |
{
'aws_cognito_identity_pool_id': '${YourUserPool}',
'aws_sign_in_enabled': 'enable',
'aws_user_pools_mfa_type': 'OFF',
}
AdvancedUsage:
Description: use Pseudo Parameters and/or resources attributes
Value: !Sub |
{
'aws_region': '${AWS::Region}',
'user_pool_arn': '${YourUserPool.Arn}',
}
I found out how to do this using Join
AmplifyConfig:
Description: key/values to be passed to Amplify.configure(config);
Value:
Fn::Join:
- ''
- - "{"
- "\n 'aws_cognito_identity_pool_id':"
- Ref : IdentityPool
- "\n 'aws_user_pools_id':"
- Ref : UserPool
- "\n 'aws_user_pools_web_client_id':"
- Ref : UserPoolClient
- ",\n 'aws_cognito_region': '${self:provider.region}'"
- ",\n 'aws_sign_in_enabled': 'enable'"
- ",\n 'aws_user_pools': 'enable'"
- ",\n 'aws_user_pools_mfa_type': 'OFF'"
- "\n}"
This works but it's kinda ugly. I'm going to leave this answer unaccepted for a while to see if anyone can show how to do this with Fn::Sub.
Using YAML you could compose this simply:
Outputs:
AmplifyConfig:
Description: key/values to be passed to Amplify.configure(config);
Value: !Sub '
{
"aws_cognito_identity_pool_id": "${IdentityPool}",
"aws_sign_in_enabled": "enable",
"aws_user_pools_mfa_type": "OFF",
}'
Leaving this here as I encountered a Base64 encoding error when doing something similar and this question came up when searching for
a solution.
In my case I was a using multi line string + !Sub to populate UserData and receiving the following error in AWS Cloudformation.
Error:
Invalid BASE64 encoding of user data. (Service: AmazonEC2; Status
Code: 400; Error Code: InvalidUserData.Malformed; Request ID: *;
Proxy: null)
Solution:
Can be solved by combining two built in Cloudformation functions; Fn::Base64 and !Sub:
UserData:
Fn::Base64: !Sub |
#!/bin/bash
echo ${SomeVar}

why does my swagger-server generate errors?

I got following errors about the swagger yaml when starting index.js in nodejs-server from "Generate Server" on Swagger Editor.
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/2: Not a valid parameter definition
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/2: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/2: Missing required property: $ref
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/1: Not a valid parameter definition
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/1: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/1: Missing required property: $ref
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/0: Not a valid parameter definition
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/0: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/0: Missing required property: $ref
#/paths/~1botManagement~1stopScenario~1/post/parameters/2: Not a valid parameter definition
#/paths/~1botManagement~1stopScenario~1/post/parameters/2: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1stopScenario~1/post/parameters/2: Missing required property: $ref
#/paths/~1botManagement~1stopScenario~1/post/parameters/1: Not a valid parameter definition
#/paths/~1botManagement~1stopScenario~1/post/parameters/1: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1stopScenario~1/post/parameters/1: Missing required property: $ref
#/paths/~1botManagement~1stopScenario~1/post/parameters/0: Not a valid parameter definition
#/paths/~1botManagement~1stopScenario~1/post/parameters/0: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1stopScenario~1/post/parameters/0: Missing required property: $ref
#/paths/~1botManagement~1restartScenario~1/post/parameters/2: Not a valid parameter definition
#/paths/~1botManagement~1restartScenario~1/post/parameters/2: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1restartScenario~1/post/parameters/2: Missing required property: $ref
#/paths/~1botManagement~1restartScenario~1/post/parameters/1: Not a valid parameter definition
#/paths/~1botManagement~1restartScenario~1/post/parameters/1: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1restartScenario~1/post/parameters/1: Missing required property: $ref
#/paths/~1botManagement~1restartScenario~1/post/parameters/0: Not a valid parameter definition
#/paths/~1botManagement~1restartScenario~1/post/parameters/0: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1restartScenario~1/post/parameters/0: Missing required property: $ref
#/paths/~1botManagement~1startScenario~1/post/parameters/2: Not a valid parameter definition
#/paths/~1botManagement~1startScenario~1/post/parameters/2: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1startScenario~1/post/parameters/2: Missing required property: $ref
#/paths/~1botManagement~1startScenario~1/post/parameters/1: Not a valid parameter definition
#/paths/~1botManagement~1startScenario~1/post/parameters/1: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1startScenario~1/post/parameters/1: Missing required property: $ref
#/paths/~1botManagement~1startScenario~1/post/parameters/0: Not a valid parameter definition
#/paths/~1botManagement~1startScenario~1/post/parameters/0: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1startScenario~1/post/parameters/0: Missing required property: $ref
yaml file is below.
swagger: "2.0"
info:
description: I wrote something but can't describe it.
version: 1
title: I wrote something but can't describe it.
termOfService: I wrote something but can't describe it.
contact:
email: xxxx#xxxx
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
host: xxxx.xxxx.xxxx.xxxx
basePath: /v1
tags:
- name: I wrote something but can't describe it.
schemes:
- https
paths:
/XXXXXXXXXX:
get:
summary: I wrote something but can't describe it.
description: I wrote something but can't describe it.
responses:
200:
description: Successful response
schema:
type: object
properties:
pid:
type: integer
format: int64
example: 0
name:
type: string
example: sample
pm2_env:
type: object
example: {username:sample, windowsHide:true...}
pm_id:
type: integer
format: int64
example: 0
monit:
type: object
example: {memory:0, cpu:0}
404:
description: API not found
500:
description: Internal server error
/xxxxx/xxxxx:
post:
summary: I wrote something but can't describe it.
description: I wrote something but can't describe it.
parameters:
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: true
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
responses:
200:
description: Successful response
schema:
type: object
properties:
scenario:
type: string
example: sample.js
status:
type: string
example: I wrote something but can't describe it.
400:
description: I wrote something but can't describe it.
404:
description: "API not found"
500:
description: "Internal server error"
/xxxxx/xxxxx/:
post:
summary: I wrote something but can't describe it.
description:
I wrote something but can't describe it.
parameters:
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: true
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
responses:
200:
description: Successful response
schema:
type: object
properties:
scenario:
type: string
example: sample.js
status:
type: string
example: I wrote something but can't describe it.
400:
description: Bad request
404:
description: API not found
500:
description: Internal server error
/xxxxx/xxxxx/:
post:
summary: I wrote something but can't describe it.
description:
I wrote something but can't describe it.
parameters:
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: true
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
responses:
200:
description: Successful response
schema:
type: object
properties:
scenario:
type: string
example: sample.js
status:
type: string
example: I wrote something but can't describe it.
400:
description: Bad request
404:
description: API not found
500:
description: Internal server error
/xxxxx/xxxxx/:
delete:
summary: I wrote something but can't describe it.
description:
I wrote something but can't describe it.
parameters:
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: true
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
responses:
200:
description: Successful response
schema:
type: object
properties:
scenario:
type: string
example: sample.js
status:
type: string
example: I wrote something but can't describe it.
400:
description: Bad request
404:
description: API not found
500:
description: Internal server error
It looks the missing property of "$ref".
I know what this property is used. But I don't need any reference to other docs.
In this case, how can I solve this problems?
Your definition has syntax errors.
1) version requires a string value, so it should be version: '1', not version: 1. Without quotes 1 is parsed as a number.
2) example: {username:sample, windowsHide:true...} is not valid YAML, it should be
example:
username: sample
windowsHide: true
or using JSON syntax:
example: {"username": "sample", "windowsHide": true}
Same for other inline object examples.
3) Operations that use in: formData parameters should specify application/x-www-form-urlencoded or multipart/form-data in the consumes keyword:
consumes:
- application/x-www-form-urlencoded
It's hard to say what else might be wrong without seeing your actual definition. You can paste your YAML into https://editor.swagger.io to check for syntax errors, or if your definition has a public URL, use the online validator
http://online.swagger.io/validator/debug?url=YOUR_URL

Grok Filter want to see only the processname

I want to see only the Process cmd.exe.
Example:
New Process Name: C:\Windows\System32\cmd.exe Token Elevation Type: %%1938 Creator Process ID: 0x1a0`enter code here`
Grok Filter:
New Process Name: %{GREEDYDATA}\\%{GREEDYDATA:Process}
Output:
{
"Process": [
[
"cmd.exe Token Elevation Type: %%1938 Creator Process ID: 0x1a0`enter code here`"
]
]
}
How i get to see only cmd.exe and not Token Elevation Type: %%1938 Creator Process ID: 0x1a0`enter?
GREEDYDATA usually means "everything". I find it usually not be useful except at the end of a pattern (as a catch-all).
So, you're asking for everything after the backslash, which is what you're getting.
How about:
New Process Name: %{GREEDYDATA}\\%{NOTSPACE:Process}

Sails-mongo many to many association not working

I am using sails 0.10.5 , and i have two models as below for many to many relation. but i am getting error while lifting app.
model 1) Category.js
attributes: {
name: {
type: 'string',
required: true
},
features: {
type: 'array'
},
desc: {
type: 'string'
},
sub_cats: {
collection: 'SubCategory',
via: 'cats',
dominant: true
}
}
model 2) SubCategory.js
attributes: {
cats: {
collection: 'Category',
via: 'sub_cats'
},
name: {
type: 'string',
required: true
},
features: {
type: 'array'
},
desc: {
type: 'string'
}
}
Now while lifting sails app, this error always trigger
"C:\Program Files (x86)\JetBrains\PhpStorm 8.0.2\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" app.js
c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\utils.js:47
return hop.call(obj, prop);
^
TypeError: Cannot convert null to object
at hasOwnProperty (native)
at exports.object.hasOwnProperty (c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\utils.js:47:14)
at JoinTables.parseAttribute (c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\joinTables.js:148:26)
at c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\joinTables.js:83:22
at Array.forEach (native)
So i am confused (my code is wrong or there is some problem in sails-mongo many-many relation)
--ND
It is just a typo in SubCategory.js: It should be attributes instead of attribute.
Hopefully you've solved your problem by now! For others like me who ran into this error, balderdashy/waterline-schema just released a more helpful error message at https://github.com/balderdashy/waterline-schema/issues/17 which should help you figure out your particular problem. Because as of today (2015-04-28) npm install does not get you this most recent version, you can manually fix it by doing the following:
Navigate to node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema (note: this may be in your global sails directory)
Replace joinTables.js with https://github.com/balderdashy/waterline-schema/blob/8f5a44d076ca36edea409bf41ac2cdbf760c2c59/lib/waterline-schema/joinTables.js
I know this doesn't exactly answer your question as to what went wrong, but hopefully it will give others with that error the tools to solve it more quickly.

Resources