I want to get openapi specs from comments.
I have been using express-jsdoc-swagger to get the specs.
Is there any other way to do it?
I got extension where I have to take "comments"(files might be js,ts and so on) like this ->
/**
* GET /documents
* #summary Get all documents
* #tags Document
* #param {string} project_id.query
* #security BearerAuth
* #return {object} 200 - success response - application/json
* #example response - 200 - success response example
* {
* "results": [
* {
* "project_id": "",
* "document_html": "",
* }
* ],
* }
* #return {object} 400 - Bad request response
*/
and get the openapi specs.
I just wanna know If there are any other ways to do it, because there are some problems
why I can't use express-jsdoc-swagger.
Related
I'm using:
openapi: "3.0.0"
Swagger-jsdoc: "^6.2.5",
Swagger-ui-express: "^4.3.0",
Node: v18.8.0
I have an endpoint sending a huge amount of raw_data and I don't want to add such payload in the swagger code. To do so I create a JSON file which I'm parsing and calling it as a variable.
For jest test it worked but for swagger commented code is not working is just recognizing it as a string and not as a variable.
important pieces of my code that could help to understand my problem.
const fs = require("fs")
const phonationRaw_data = fs.readFileSync("payloads/ phonationData.json");
const phonationParsedData = JSON.parse(phonationRaw_data);
so phonationParsedData is my variable containing a big amounts of raw data
//! Schema POST
/**
* #swagger
* components:
* schemas:
* Phonation:
*
* type: object
*
* required:
* - date
* - status
* - raw_data
*
* properties:
*
* date:
* type: string
* timestamp-format: yy-MM-dd HH:mm:ss
* example: "2022-09-21 14:56:15"
*
* status:
* type: integer
* example: 3
*
* raw_data:
* type: string
* format: binary ↓↓
* → example: $ref:phonationParsedData.raw_data ←
*/
// these line is the one causing problems ↑↑
I already tried and I don't know how many more:
phonationParsedData.raw_data
phonationParsedData.raw_data (here I'm using it to )
$ref:phonationParsedData.raw_data
$ref:phonationParsedData.raw_data
${phonationParsedData.raw_data}
${phonationParsedData.raw_data}
it always logs something similar to these example:
I thought this would be shown in the docs but I'm trying to get column resizing working with Tabulator.
This page just describes how to import the plugin:
import {ResizeTableModule} from 'tabulator-tables';
But what do you with this import? I thought you could add it to Tabulator.extendModule(ResizeTableModule) but that does nothing. I couldn't find any examples using plugins modularly like this. Thanks for the help.
To get column resizing working, you can import ResizeColumnsModule as follows:
import { Tabulator, ResizeColumnsModule } from "tabulator-tables";
Tabulator.registerModule(ResizeColumnsModule)
Example: https://codesandbox.io/s/gifted-wescoff-nw337l?file=/src/index.js
As per docs correct way to extend a module is like
/**
* #param {String} moduleName
* #param {any} configs
* #param {any} newconfig
*/
Tabulator.extendModule("resizeTable", "config", {
//Your New Config
name: "__int__",
});
I am afriad as ResizeTableModule module does not expose any other config but you can define them by extending the class
import { Tabulator, ResizeColumnsModule, ResizeTableModule } from "tabulator-tables";
class MyResizeTableModule extends ResizeTableModule {
constructor(table) {
super(table);
this.config = MyResizeTableModule.config;
}
}
MyResizeTableModule.config = {};
Tabulator.registerModule([MyResizeTableModule, ResizeColumnsModule]);
/**
* #param {String} moduleName
* #param {any} configs
* #param {any} newconfig
*/
Tabulator.extendModule("resizeTable", "config", {
//Your New Config
name: "__int__",
});
See Codesandbox
I have a UE script that saves entry from a custom record into rejection reason on vendor bill. This part is working fine and this script is able to save the rejection reason to overcome the limitations of the Employee Centre users that do not have write access on vendor bill. However, since I am fairly new to scripting, I am not able to delete all the records from the custom record every time before the script executes. If someone could help me with the related code to delete all the existing records in the custom record, that would be great. I am adding my existing code for your reference.
/**
#NApiVersion 2.x
#NScriptType UserEventScript
#NModuleScope SameAccount
*/
define(['N/record'],
function(record) {
/**
* Function definition to be triggered before record is loaded.
*
* #param {Object} scriptContext
* #param {Record} scriptContext.newRecord - New record
* #param {string} scriptContext.type - Trigger type
* #param {Form} scriptContext.form - Current form
* #Since 2015.2
*/
function beforeLoad(scriptContext)
{
}
/**
* Function definition to be triggered before record is loaded.
*
* #param {Object} scriptContext
* #param {Record} scriptContext.newRecord - New record
* #param {Record} scriptContext.oldRecord - Old record
* #param {string} scriptContext.type - Trigger type
* #Since 2015.2
*/
function beforeSubmit(scriptContext)
{
}
/**
* Function definition to be triggered before record is loaded.
*
* #param {Object} scriptContext
* #param {Record} scriptContext.newRecord - New record
* #param {Record} scriptContext.oldRecord - Old record
* #param {string} scriptContext.type - Trigger type
* #Since 2015.2
*/
function afterSubmit(scriptContext)
{
// Get the value of the Reject reason
var rejReason = scriptContext.newRecord.getValue({
fieldId: 'custrecord165' // Change this according to the internal id of the Field Reject Reason in the Custom Record Created
});
// Get the ID of the Vendor Bill Reject reason
var venbillID = scriptContext.newRecord.getValue({
fieldId: 'custrecord166' // Change this according to the internal id of the Field Reject Reason in the Custom Record Created
});
// populate the Reject Reason in the Vendor Bill Rejection Reason field
var id = record.submitFields({
type: record.Type.VENDOR_BILL,
id: venbillID,
values: {
custbody_rt_vendbill_rej_reason: rejReason //'testMSG01'
//custrecord165: 'testMSG'//rejReason // Change custbody1 to the internal id of the custom field Reject Reason in the Vendor Bill Record
},
options: {
enableSourcing: false,
ignoreMandatoryFields : true
}
});
}
return {
beforeLoad: beforeLoad,
beforeSubmit: beforeSubmit,
afterSubmit: afterSubmit
};
});
I have implemented such a requirement before. As I understand from your question, you need to delete all the entries from the custom record every time the script executes. This part can be added in the beginning of your code. Below is the sample code to help you with deleting all data from the custom record. In below snippet you need to replace "customrecord_tracker" with your custom record internal id and make other id changes as per your requirement
Please let me know how this goes for you! Happy coding! :)
//Search on the custom record to get the all the results
var searchTracker = search.create({
type: 'customrecord_tracker',
filters: ['isinactive', search.Operator.IS,'F'],
columns:['internalid']
});
var searchIcResults = searchTracker.run();
log.debug('searchIcResults',searchIcResults);
//Get the range of 1000 search results, if your search results are going to be less than 999 then you need not change anything here
var jeSearch = searchIcResults.getRange({
start: 0,
end: 999
});
if (jeSearch && jeSearch.length > 0) {
for (var itr = 0; itr < jeSearch.length; itr++) {
var internalId = jeSearch[itr].getValue({
name: 'internalid'
});
var deleteCustRecord = record.delete({
type: 'customrecord_tracker',
id: internalId
});
}
}
I am creating an add-on which should create worklogs automatically. I am using node-js (jira-connector).
I managed to get Issues, and to create new, but I am getting the error:
UnhandledPromiseRejectionWarning: Error: Missing 'worklog' property
when I want to add worklogs to a Issue
function updateIssueInJira()
{
var jira = getoAuth();
try {
return new Promise(() => {
jira.issue.addWorkLog({
opts: {
issueKey: 'NTS-4',
adjustEstimate: 'new',
newEstimade: '2d',
worklog: 'Testing'
}
})
});
} catch (error) {
console.log(error);
}
}
The definition of addWorkLog is:
/**
* Adds a new worklog entry to an issue.
*
* #method addWorkLog
* #memberOf IssueClient#
* #param {Object} opts The options to pass to the API. Note that this object must contain EITHER an issueId or
* issueKey property; issueId will be used over issueKey if both are present.
* #param {string} [opts.issueId] The id of the issue. EX: 10002
* #param {string} [opts.issueKey] The Key of the issue. EX: JWR-3
* #param {string} [opts.adjustEstimate] Allows you to provide specific instructions to update the remaining time
* estimate of the issue. Valid values are
* * "new" - sets the estimate to a specific value
* * "leave"- leaves the estimate as is
* * "manual" - specify a specific amount to increase remaining estimate by
* * "auto"- Default option. Will automatically adjust the value based on the
* new timeSpent specified on the worklog
* #param {string} [opts.newEstimate] (required when "new" is selected for adjustEstimate) the new value for the
* remaining estimate field. e.g. "2d"
* #param {string} [opts.reduceBy] (required when "manual" is selected for adjustEstimate) the amount to reduce the
* remaining estimate by e.g. "2d"
* #param {Object} opts.worklog See {#link: https://docs.atlassian.com/jira/REST/latest/#d2e1106}
* #param [callback] Called after the worklog is added.
* #return {P
romise} Resolved after the worklog is added.
*/
this.addWorkLog = function (opts, callback) {
if (!opts.worklog) {
throw new Error(errorStrings.NO_WORKLOG_ERROR);
}
var options = this.buildRequestOptions(opts, '/worklog', 'POST', opts.worklog, {
newEstimate: opts.newEstimate,
reduceBy: opts.reduceBy,
adjustEstimate: opts.adjustEstimate
});
return this.jiraClient.makeRequest(options, callback, 'Worklog Added');
};
Under getoAuth() I am doing my oAuth authentification, and I want to add the worklog to the Issue NTS-4.
I found a solution. I am sending the input directly via REST Call (POST). For that, I am using 'request'
function updateIssueInJira(oauth)
{
var testjson = {
author: {
emailAddress: "myemail"
},
comment: "Test",
timeSpentSeconds: "2700"
}
request.post({
url:'https://thelocation.com/rest/api/2/issue/ISSUEKEY/worklog/',
oauth:oauth,
json:true,
body: testjson
},
function (e, r, user) {
console.log(user)
});
}
How to get the time taken for each selenium command using c# code,Means i want to get the time taken by webpage for HTTP Request and response,as we can see in the firebug->Net->HTML if we do any action.
Please some one suggest me how to record that api call timings.
Thanks,
Eswar
you can use code mentioned below it will return you a dictionary containing performance metrics.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using OpenQA.Selenium;
namespace AutomatedTester.PagePerf
{
public static class Extensions
{
public static Dictionary<string,object> WebTimings(this IWebDriver driver)
{
var webTiming = (Dictionary<string, object>)((IJavaScriptExecutor)driver)
.ExecuteScript(#"var performance = window.performance || window.webkitPerformance || window.mozPerformance || window.msPerformance || {};
var timings = performance.timing || {};
return timings;");
/* The dictionary returned will contain something like the following.
* The values are in milliseconds since 1/1/1970
*
* connectEnd: 1280867925716
* connectStart: 1280867925687
* domainLookupEnd: 1280867925687
* domainLookupStart: 1280867925687
* fetchStart: 1280867925685
* legacyNavigationStart: 1280867926028
* loadEventEnd: 1280867926262
* loadEventStart: 1280867926155
* navigationStart: 1280867925685
* redirectEnd: 0
* redirectStart: 0
* requestEnd: 1280867925716
* requestStart: 1280867925716
* responseEnd: 1280867925940
* responseStart: 1280867925919
* unloadEventEnd: 1280867925940
*/
return webTiming;
}
}
}