With swagger 2.0 spec, i'm describing an 'operation' to add new resources:
A POST request with 3 parameters:
{
name: "username",
in: "header",
description: "New user unsername",
required: true,
type: "string"
},
{
name: "password",
in: "header",
description: "New user password",
required: true,
type: "string"
},
{
name: "pensis",
in: "body",
description: "New pensis to create",
required: true,
schema: {
properties: {
content: {
type: "string",
description: "Content of this pensis stored as markdown text"
}
}
}
}
I setup the POST request with the 3 previous parameters:
username: "Bob",
password: "Yo!",
pensis: {
content: "The content"
}
I send the POST request, and when i parse it using swagger-tool metadata 0.8.6 middleware, i get a strange response :
The value of req.swagger.params.pensis.value provided by this middleware is not:
{ content: 'The content' }
but:
{ content: 'The content',
username: 'ClementVidal',
password: 'r'
}
Do you have any idea about why those 3 parameters are merged together inside the same pensis object ??
Thanks for your help
Clément Vidal
Related
Trying to use x-ms-dynamic-values (which working as expected) and x-ms-dynamic-schema (which doesn't seems to work)
I only getting the body param name dynamicActionSchema instead of the dynamic schema.
Those are my paths:
paths:
/api/v1/actions:
get:
description: Get lists
summary: Get's action list you have access to
operationId: GetActionsList
parameters:
- {in: query, name: include_attributes, default: ref, type: string, description: The
number of items to skip before starting to collect the result set}
responses:
'200':
description: OK
schema: {$ref: '#/definitions/GetLists'}
/api/v1/actions/{actionId}:
get:
description: Gets the schema of the selected action
summary: Get's the schema of the selected action
operationId: GetActionSchema
parameters:
- {name: actionId, in: path, required: true, type: string, x-ms-summary: Select
Action}
responses:
'200':
description: OK
schema: {type: object}
/api/v1/executions/{action}:
post:
description: Executing ST action - Uses Dynamic values and dynamic schema to
draw form
summary: Executing ST action
operationId: ExecuteSTAction
parameters:
- name: action
type: string
in: path
description: Select action you want to execute
required: true
x-ms-summary: Select Action
x-ms-dynamic-values: {operationId: GetActionsList, value-path: ref}
- name: dynamicActionSchema
in: body
description: Dynamic Schema of items in selected action
schema:
type: object
x-ms-dynamic-schema:
operationId: GetActionSchema
parameters:
actionId: {parameter: action}
value-path: parameters
responses:
'201': {description: Executed}
definitions:
GetLists:
type: array
items:
type: object
properties:
ref: {type: string}
required: [ref]
security:
- API Key: []
Dynamic schema operation output sample:
{
"parameters": {
"tags": {
"description": "List of tags for item.",
"required": false,
"type": "array",
"position": 12
},
"env": {
"description": "Environment variables which will be available to the script.",
"type": "object"
},
"detected": {
"description": "The datetime for detecting the item.",
"required": true,
"type": "string",
"position": 6
},
"description": {
"description": "The description of the item.",
"required": false,
"type": "string",
"position": 2
}
...
}
}
Full example:
https://github.com/microsoft/PowerPlatformConnectors/blob/070009ba5681fd57ee6cc61d2a380123712a088f/certified-connectors/Ticketing.events/apiDefinition.swagger.json
MS docs:
https://learn.microsoft.com/en-us/connectors/custom-connectors/openapi-extensions#use-dynamic-schema
Open thread in Power Apps forum:
https://powerusers.microsoft.com/t5/Building-Power-Apps/Dynamic-schema-doesn-t-seems-to-work-based-on-a-body-parameter/m-p/1373866#M357492
Found my issue, schema should be in the form of:
{
"parameters": {
"type": "object",
"properties": {
"debug": {
"default": false,
"required": false,
"description": "Enable runner debug mode.",
"type": "boolean"
},
...
}
}
}
I am using node-ews for sending Email through MicroSoft Exchange using my corporate credendials.
But I cannot figure out how to attach .xlsx files to an email from local disk storage. It seems that there is no simple Path tag.
This is what i have
const ewsArgs = {
attributes: {
MessageDisposition: 'SendAndSaveCopy',
},
SavedItemFolderId: {
DistinguishedFolderId: {
attributes: {
Id: 'sentitems',
},
},
},
Items: {
Message: {
ItemClass: 'IPM.Note',
Subject: 'Subject',
Body: {
attributes: {
BodyType: 'Text',
},
$value: 'Bodytext',
},
ToRecipients: {
Mailbox: {
EmailAddress: 'email#email.ru',
},
},
IsRead: 'false',
Attachments: {
FileAttachment: [{
Name: 'filename.xlsx',
IsInline: false,
ContentType: 'text/xlsx',
ContentLocation: 'filename.xlsx',
}]
}
},
},
};
What am I doing wrong?
Check your contentLocation. You need to give the correct path of the file you want to attach. But you just provided the filename.
Content-Type: application/vnd.ms-excel
i use Express-js and express graphQL module to create my endpoint and web service ;
i am looking for way to create custom response in graphQL my endpoint is simple
select books from database my response is
{
"data": {
"books": [
{
"id": "5b5c02beab8dc1182b2e0a03",
"name": "dasta"
},
{
"id": "5b5c02c0ab8dc1182b2e0a04",
"name": "dasta"
}
]
}
}
but in need something like this
{
"result": "success",
"msg" : "list ...",
"data": [
{
"id": "5b5c02beab8dc1182b2e0a03",
"name": "dasta"
},
{
"id": "5b5c02c0ab8dc1182b2e0a04",
"name": "dasta"
}
]
}
here is my bookType
const BookType = new GraphQLObjectType({
name: 'Book',
fields: () => ({
id: {type: GraphQLID},
name: {type: GraphQLString},
genre: {type: GraphQLString},
author_id: {type: GraphQLString},
author: {
type: AuthorType,
resolve(parent, args) {
return Author.findById(parent.author_id);
}
}
})
});
That's not a legal GraphQL response. As per section 7.1 of the spec, after describing the data, errors, and extensions: top-level keys:
... the top level response map must not contain any entries other than the three described above.
You might put this data into extensions; or make it an explicit part of your GraphQL API; or simply let "success" be implied by the presence of a result and the lack of an error.
I have two models setup:
ShopsModel
var ShopsSchema = new mongoose.Schema({
name: {
type: String,
required: true
}
});
var ShopsModel = mongoose.model("Shops", ShopsSchema);
FieldGroupsModel
var FieldGroupsSchema = new mongoose.Schema({
title: {
type: String,
required: true
},
fields: [{
label: {
type: String,
required: true
},
handle: {
type: String,
required: true
}
}],
shop: {
type: mongoose.Schema.Types.ObjectId,
ref: "Shops"
}
});
var FieldGroupsModel = mongoose.model("FieldGroups", FieldGroupsSchema)
Each FieldGroups instance has a ShopsModel associated with it.
I need to create an index for the FieldGroupsModel fields[i].handle value, this index needs two rules; it needs to be unique to each FieldGroupsModel instance, so this data would be invalid:
{
title: "Some field group title here",
fields: [
{
label: "Some label 1"
handle: "some-label-1"
},
{
label: "Some label 1"
handle: "some-label-1" // Error: `some-label-1` already exists as a value of `fields[i].handle`.
}
],
shop: {
"$oid": "1"
}
}
The second rule is that the first rule should only be in place for FieldGroupsModel instances which share the same shop value. So this data would be invalid:
// First bit of data
{
title: "Some field group title here",
fields: [
{
label: "Some label 1"
handle: "some-label-1"
}
],
shop: {
"$oid": "1"
}
}
// Second bit of data
{
title: "Another field group title here",
fields: [
{
label: "Some label 1"
handle: "some-label-1" // Error: `some-label-1` already exists as a value of `fields[i].handle` of a document which shares the same `shop` value.
}
],
shop: {
"$oid": "1"
}
}
However, this would be valid:
// First bit of data
{
title: "Some field group title here",
fields: [
{
label: "Some label 1"
handle: "some-label-1"
}
],
shop: {
"$oid": "1"
}
}
// Second bit of data
{
title: "Another field group title here",
fields: [
{
label: "Some label 1"
handle: "some-label-1" // This is valid because there's no other documents with the same `shop` value with the same `fields[i].handle` value.
}
],
shop: {
"$oid": "2"
}
}
I'm quite new to Mongo and Mongoose so any help here would be greatly appreciated! :)
You call the index method on your Schema object to do that as shown here. For your case it would be something like:
FieldGroupsSchema.index({"shop": 1, "fields.handle": 1}, {unique: true});
Please read the MongoDB documentation about Compound Indexes for more detail.
I have been working on a node.js odata server based on this example: How to set up a nodejs OData endpoint with odata-server
I have everything working... I can read, update, insert, delete. But I am trying to associate a Journal with a Tasks and I am having problems.
I have tried several different ways outlined here: Operations (OData Version 2.0)
Here is my code:
/* global $data */
require('odata-server');
$data.Class.define("Task", $data.Entity, null, {
Id: { type: "id", key: true, computed: true, nullable: false },
Title: { type: "string", required: true, maxLength: 200 },
Journals: { type: "array", elementType: "Journal"
, inverseProperty: "Task" }
});
$data.Class.define("Journal", $data.Entity, null, {
Id: { type: "id", key: true, computed: true, nullable: false },
Entry: { type: "string" },
DateInserted: { type: "string" },
Task: { type: "object", elementType: "Task" , inverseProperty: "Journals" }
});
$data.EntityContext.extend("obb", {
Tasks: { type: $data.EntitySet, elementType: Task },
Journals: { type: $data.EntitySet, elementType: Journal }
});
$data.createODataServer(obb, '/api-v0.1', 2046, 'localhost');
Question:
Is this feature even available from odata-server what would the post look like to link a Journal to a Task?
I am using fiddler2 and composing a POST I have tried these urls:
//localhost:2046/api-v0.1/Tasks('the-id-of-a-task')/Journals
//localhost:2046/api-v0.1/Tasks('the-id-of-a-task')/Journals/$link
post body's I have tried:
{"Entry":"This is a test"}
{"url":"http://localhost:2046/api-v0.1/Journals('id-of-a-journal-in-the-db')"}
I have even tried to build out and post a Task with journals together and that didn't work.
Any help would be greatly appreciated. Thanks.