Jenkins GDSL : how to recognize build job in declarative syntax? - intellij-idea

In a declarative pipeline, I have this job call :
build job: 'myJob', parameters: [
string(name: 'PARAM1', value: 'value1'),
string(name: 'PARAM2', value: 'value2'),
], wait: true
I would like Intellij recognizes this syntax with a GDSL file. Currently, I have in my GDSL file :
method(name: 'build', type: 'Object', namedParams: [
parameter(name: 'job', type: 'java.lang.String'),
parameter(name: 'parameters', type: 'java.util.List'),
parameter(name: 'propagate', type: 'boolean'),
parameter(name: 'quietPeriod', type: 'java.lang.Integer'),
parameter(name: 'wait', type: 'java.lang.Boolean')])
But defining a java.util.List type for parameter is incorrect : IntelliJ do not expect to have string() as parameter.
Any idea ?

Related

Discord.js: Add input field to slash command

Example
Hey guys,
can anyone tell me how to add such an input field to a slash command in Discord.js (v.14)?
Example above.
Look at the discord.js doc here
When you create a command, you have just to set the options parameters :
client.application.commands.create({
type: "CHAT_INPUT",
name: "mycommand",
description: "My awesome command",
options: [
{
type: "STRING",
name: "firstparameter",
description: "My first parameter",
required: true
}
]
});

how to remove non-schema params from the query

according to the fastify 4.0 docs, the default options for Ajv include removeAdditional: true. I have a queryString schema, and when I send a query with a param that is not in the schema, I expect that param to be removed. But no such thing happens. The schema itself is pretty run-of-the-mill
querystring: {
type: "object",
properties: { … }
}
Some of my params are of type array, and there too I would like any additional values (outside of those specified via enum to be removed. How can I achieve this?
update: I am adding the actual schema below (with some info snipped for brevity)
{
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'$id': 'https://example.com/treatments.schema.json',
title: 'Treatments',
summary: 'Fetches treatments',
description: 'Treatments are…',
response: {},
querystring: {
type: 'object',
additionalProperties: false,
properties: {
treatmentId: {
type: "string",
maxLength: 32,
minLength: 32,
description: "A 32 character string: treatmentId=388D179E0D564775C3925A5B93C1C407"
},
… <snipped> …
}
},
tags: [ 'zenodeo' ]
}
I know the schema is being validated because http://localhost:3010/v3/treatments?treatmentId=foo gives an error {"statusCode":400,"error":"Bad Request","message":"querystring/treatmentId must NOT have fewer than 32 characters"} (that is good 👍🏽) but the additionalProperties: false constraint is still not working because http://localhost:3010/v3/treatments?foo=bar gives no error and foo is also not removed from request.query (that is not good 👎🏽)
With removeAdditional: true you must still set additionalProperties: false on your schema:
querystring: {
type: "object",
properties: { … },
additionalProperties: false
}
See https://ajv.js.org/json-schema.html#additionalproperties
You can also change the default behavior to removeAdditional: 'all' in which case you don't have to set additionalProperties: false on your schema.
See about halfway down the page here: https://www.fastify.io/docs/latest/Reference/Validation-and-Serialization/

How to nest a JSON payload under a named parameter in open api 3.0 [duplicate]

This question already has answers here:
Swagger: How to have a property reference a model in OpenAPI 2.0 (i.e. nest the models)?
(2 answers)
Closed 2 years ago.
I'm trying to describe an API endpoint that receives a PUT request with the following JSON payload:
{
"product": {
"name: "foo",
"brand": "bar"
}
}
Here is a sample of the definition:
components:
schemas:
Product:
type: object
required:
- name
- brand
properties:
name:
type: string
brand:
type: string
paths:
/products/{id}:
parameters:
- name: id
in: path
schema:
type: integer
required: true
put:
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
However, this produces the following JSON payload (it's missing the "product" key):
{
"name: "foo",
"brand": "bar"
}
I tried this:
parameters:
- name: product
in: body
schema:
type: object
properties:
product:
type: object
schema:
$ref: '#/components/schemas/Product'
But that doesn't work. Any ideas?
Your second example is almost correct, just change this part
schema:
type: object
properties:
product:
type: object
schema:
$ref: '#/components/schemas/Product'
to
schema:
type: object
properties:
product:
$ref: '#/components/schemas/Product'
Note the $ref is used directly under the property name.

Validation error with api connect on bluemix: Data does not match any schemas from 'oneOf'

I'm getting the error Data does not match any schemas from 'oneOf' with the following spec:
product: 1.0.0
info:
name: account-information
title: Account Information
version: 1.0.10
termsOfService: >-
These API are a PSD2 implementation example. The service might be
discontinued at any time
visibility:
view:
type: public
subscribe:
type: authenticated
plans:
premium:
title: Premium
apis: {}
rate-limit:
value: 1000/1minute
hard-limit: true
approval: true
default:
title: Default Plan
description: Default Plan
approval: false
rate-limit:
value: 100/hour
hard-limit: true
apis:
account:
$ref: account.yaml
subscription:
$ref: subscription.yaml
The full error message:
Message : "Data does not match any schemas from "oneOf"", Chemin de données : "", Chemin de schéma : "/oneOf"
Message : "Additional properties not allowed", Chemin de données : "/name", Chemin de schéma : "/oneOf/0/additionalProperties"
I don't understand where does the error come from and how to solve it.
For API Connect I believe you want to use x-ibm-name instead of name. I was able to get the following spec validated using your above example:
info:
title: Account Information
x-ibm-name: account-information
version: 1.0.10
visibility:
view:
type: public
subscribe:
type: authenticated
plans:
premium:
title: Premium
apis: {}
rate-limit:
value: 1000/1minute
hard-limit: true
approval: true
default:
title: Default Plan
description: Default Plan
approval: false
rate-limit:
value: 100/hour
hard-limit: true
apis:
account:
$ref: account.yaml
subscription:
$ref: subscription.yaml
Note: I also removed the product field.
You could also use the Design tab to have API Connect create the source automatically in the correct format:

Unable to create S3Buckets through serverless.yml

I simply tried to add a new S3Bucket into the Resources section and the stack is not being built anymore:
resources:
Resources:
myBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: prefix-${self:custom.env.myvar}-myBucket
and the error I'm getting is not helping too much:
Template format error: Unresolved resource dependencies
[] in the Resources block of the template (nothing between the [] that could indicate what to look for)
Any idea what's going on?
I'm running serverless v1.5.0
serverless.yml
service: myService
frameworkVersion: "=1.5.0"
custom:
env: ${file(./.variables.yml)}
provider:
name: aws
runtime: nodejs4.3
stage: ${opt:stage, self:custom.env.stage}
region: ${self:custom.env.region}
profile: myProfile-${opt:stage, self:custom.env.stage}
memorySize: 128
iamRoleStatements:
- Effect: "Allow"
Action:
- "lambda:InvokeFunction"
Resource: "*"
- Effect: "Allow"
Action:
- "s3:ListBucket"
Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
- Effect: "Allow"
Action:
- "s3:PutObject"
Resource:
Fn::Join:
- ""
- - "arn:aws:s3:::"
- "Ref" : "ServerlessDeploymentBucket"
- "Ref" : ""
functions:
myFunction:
handler: functions/myFunction.handler
name: ${opt:stage, self:custom.env.stage}-myFunction
resources:
Resources:
myBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: myService-${opt:stage, self:custom.env.myVar}-myBucket
The Reference to an empty-string in your iamRoleStatements section, - "Ref" : "", is likely causing the Unresolved resource dependencies [] error. Remove this line from your template, since it seems to be unnecessary.