mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 03:34:35 +00:00
fix: add _debug as optional query param in swagger apis for GET stp/execute
This commit is contained in:
@@ -792,7 +792,7 @@ paths:
|
|||||||
- {type: string}
|
- {type: string}
|
||||||
- {type: string, format: byte}
|
- {type: string, format: byte}
|
||||||
description: 'Execute Code on the Specified Runtime'
|
description: 'Execute Code on the Specified Runtime'
|
||||||
summary: 'Run Code and Return Webout Content and Log'
|
summary: "Run Code and Return Webout Content, Log and Print output\nThe order of returned parts of the payload is:\n1. Webout (if present)\n2. Logs UUID (used as separator)\n3. Log\n4. Logs UUID (used as separator)\n5. Print (if present and if the runtime is SAS)\nPlease see"
|
||||||
tags:
|
tags:
|
||||||
- Code
|
- Code
|
||||||
security:
|
security:
|
||||||
@@ -1805,6 +1805,15 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
example: /Projects/myApp/some/program
|
example: /Projects/myApp/some/program
|
||||||
|
-
|
||||||
|
description: 'Optional query param for setting debug mode'
|
||||||
|
in: query
|
||||||
|
name: _debug
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
format: double
|
||||||
|
type: number
|
||||||
|
example: 131
|
||||||
post:
|
post:
|
||||||
operationId: ExecutePostRequest
|
operationId: ExecutePostRequest
|
||||||
responses:
|
responses:
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
getRunTimeAndFilePath
|
getRunTimeAndFilePath
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { MulterFile } from '../types/Upload'
|
import { MulterFile } from '../types/Upload'
|
||||||
|
import { debug } from 'console'
|
||||||
|
|
||||||
interface ExecutePostRequestPayload {
|
interface ExecutePostRequestPayload {
|
||||||
/**
|
/**
|
||||||
@@ -29,14 +30,23 @@ export class STPController {
|
|||||||
*
|
*
|
||||||
* @summary Execute a Stored Program, returns _webout and (optionally) log.
|
* @summary Execute a Stored Program, returns _webout and (optionally) log.
|
||||||
* @param _program Location of code in SASjs Drive
|
* @param _program Location of code in SASjs Drive
|
||||||
|
* @param _debug Optional query param for setting debug mode
|
||||||
* @example _program "/Projects/myApp/some/program"
|
* @example _program "/Projects/myApp/some/program"
|
||||||
|
* @example _debug 131
|
||||||
*/
|
*/
|
||||||
@Get('/execute')
|
@Get('/execute')
|
||||||
public async executeGetRequest(
|
public async executeGetRequest(
|
||||||
@Request() request: express.Request,
|
@Request() request: express.Request,
|
||||||
@Query() _program: string
|
@Query() _program: string,
|
||||||
|
@Query() _debug?: number
|
||||||
): Promise<string | Buffer> {
|
): Promise<string | Buffer> {
|
||||||
const vars = request.query as ExecutionVars
|
let vars = request.query as ExecutionVars
|
||||||
|
if (_debug) {
|
||||||
|
vars = {
|
||||||
|
...vars,
|
||||||
|
_debug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return execute(request, _program, vars)
|
return execute(request, _program, vars)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ stpRouter.get('/execute', async (req, res) => {
|
|||||||
if (error) return res.status(400).send(error.details[0].message)
|
if (error) return res.status(400).send(error.details[0].message)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await controller.executeGetRequest(req, query._program)
|
const response = await controller.executeGetRequest(
|
||||||
|
req,
|
||||||
|
query._program,
|
||||||
|
query._debug
|
||||||
|
)
|
||||||
|
|
||||||
if (response instanceof Buffer) {
|
if (response instanceof Buffer) {
|
||||||
res.writeHead(200, (req as any).sasHeaders)
|
res.writeHead(200, (req as any).sasHeaders)
|
||||||
|
|||||||
@@ -180,7 +180,8 @@ export const runCodeValidation = (data: any): Joi.ValidationResult =>
|
|||||||
|
|
||||||
export const executeProgramRawValidation = (data: any): Joi.ValidationResult =>
|
export const executeProgramRawValidation = (data: any): Joi.ValidationResult =>
|
||||||
Joi.object({
|
Joi.object({
|
||||||
_program: Joi.string().required()
|
_program: Joi.string().required(),
|
||||||
|
_debug: Joi.number()
|
||||||
})
|
})
|
||||||
.pattern(/^/, Joi.alternatives(Joi.string(), Joi.number()))
|
.pattern(/^/, Joi.alternatives(Joi.string(), Joi.number()))
|
||||||
.validate(data)
|
.validate(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user