Springdoc-openapi external json file with relative path for example request body - swagger

I am looking for a way to use a relative path for external JSON files while defining the example request body.
My current definition is like this:
#Operation(requestBody = #RequestBody(description = "Request", content = #Content(schema = #Schema(implementation = Request.class), examples = {
#ExampleObject(
name = "An example request",
value = "{\n" +
"\"token\":\"token\"\n" +
"}",
summary = "Request"
)}
)),summary = "summ", description = "desc")
I want to keep JSON value on an external JSON file.
I know that "externalValue" field can be used instead of "value" to reference an external json file, but it requires a URL. I want to keep it in the project file and use the relative path. I am using Open API v3.
For those who are just looking for external JSON file usage, you can use external JSON file from a URL like this:
#Operation(requestBody = #RequestBody(description = "Request", content = #Content(schema = #Schema(implementation = Request.class), examples = {
#ExampleObject(
name = "An example request",
externalValue = "http://domain/test/example.json",
summary = "Request"
)}
)),summary = "summ", description = "desc")

Related

I want to put RDF/XML format directly in SDB

In Jena, I saved RDF/XML documents in SDB using the "read()" method and even created a file with RDF/XML documents in SDB using the "write" method.
What I want to try is to save Triple directly in SDB.
Here is my code
prefix = "http://example.org/terms/";
ns = "ex";
model.setNsPrefix(ns, prefix);
prefix3 = "http://www.w3.org/1999/02/22-rdf-syntax-ns";
ns3 = "rdf";
model.setNsPrefix(ns3, prefix3);
prefix6 = "http://www.test/2022/#";
ns6 = "base";
model.setNsPrefix(ns6, prefix6);
for(i = 0; i<index; i++) {
Resource s_A = model.createResource(A[i].o);
Property p_A = model.createProperty(prefix3);
Resource s_B = model.createResource(B[i].s);
Property p_B = model.createProperty(B[i].p);
Resource s_C = model.createResource(C[i].s);
Property p_C = model.createProperty(C[i].p);
//model.add(s_A, p_A, prefix6); //wish <ex:Description rdf:about=baseURI+"ID">
model.add(s_A, p_B, B[i].o); //wish <ex:Description.type>1</ex:Description.type>
model.add(s_A, p_C, C[i].o); //wish <ex:Description.open>0</ex:Description.open>
//wish </ex:Description>
}
I know this(model.add(s_A, p_A, prefix6);) part is wrong, but I don't know which method I use to wish. I don't know what else to do here.

Acessing Post Rest Api using Power query

I am new to power BI and power query, I am trying to get the JSon data from Post rest api. But i always get a 400 error. Where am I going wrong.
let
authkey ="Bearer xxxx",
url = "https://example.com/xxx",
body = "{""objectId"":""settlement_entity"",""queryString"":""?itemrefs=settlementreference,itemdescription&perpage=12&includekeyitems=true&includeforeignkeyitems=true&includetimestamp=true&includeadditionalmeta=true""}",
Source = Json.Document(Web.Contents(url,
[
Headers = [#"Authorization"= authkey,#"Content-Type"="application/json"], Content = Text.ToBinary(body)
]
))
in
Source
Ok I fixed the issue the body was missing square bracket
let
authkey ="Bearer xxxx",
url = "https://example.com/xxx",
body = "[{""objectId"":""settlement_entity"",""queryString"":""?itemrefs=settlementreference,itemdescription&perpage=12&includekeyitems=true&includeforeignkeyitems=true&includetimestamp=true&includeadditionalmeta=true""]}",
Source = Json.Document(Web.Contents(url,
[
Headers = [#"Authorization"= authkey,#"Content-Type"="application/json"], Content = Text.ToBinary(body)
]
))
in
Source

?:0: attempt to perform arithmetic on field 'fileSize' (a nil value)

How to resolved error or possible ways to resolved it?
Guys, i've developed plugin using Lua language which can be integrate or run from Adobe's LightRoom Classic. Currently i need to upload or send a file to server but i can not. Everytime i called the POST API which is multipart/form-data error popup "?:0: attempt to perform arithmetic on field 'fileSize' (a nil value)". Not even API is being called this error pops up before API call. after debug I can assure the possible issue is in creating mimeChunks with file type.
I have developed the code like below, can any one help me out with suggestions so that i can able to resolved issue?
local filePath = assert("C:\Users\Ankit\Desktop\Hangman.PNG")
local fileName = LrPathUtils.leafName(filePath)
local mimeChunks = {}
mimeChunks[#mimeChunks + 1] = {
name = 'api_sig',
value = "test value"
}
mimeChunks[#mimeChunks + 1] = {
name = "file",
filePath = filePath,
fileName = fileName,
contentType = "application/octet-stream"
}
local postUrl = "API endpoint"
local result, hdrs = LrHttp.postMultipart(postUrl, mimeChunks)
if result then
LrDialogs.message("Form Values", result)
else
LrDialogs.message("Form Values", "API issue")
end
Eventually image or file path itself cause the issue, there are no such indications or articles related to this functionality, but yes "add-on backslash" will work out for sure. Kindly review the below code for more detailed bifurcation which pass dynamic selected file or image path.
local function uploadFile(filePath)
local fileName = LrPathUtils.leafName( filePath )
local mimeChunks = {}
mimeChunks[ #mimeChunks + 1 ] = { name = 'api_sig', value = "test value"}
mimeChunks[#mimeChunks + 1] = {
name = "file",
filePath = filePath,
fileName = fileName,
contentType = "image/jpeg" --multipart/form-data --application/octet-stream
}
import "LrTasks".startAsyncTask(
function()
local postUrl = "http://cms.local.com/api/v1/upload"
local result, hdrs = LrHttp.postMultipart(postUrl, mimeChunks)
if result then
LrDialogs.message("Image uploaded.", result)
else
LrDialogs.message("Error", "API issue")
end
end
)
end
Above uploadFile method will automatically call the API and post form-data collection. Below code is for call uploadFile function which select all the images from catalog.
for p, photo in ipairs(LrApplication.activeCatalog()) do
uploadFile(assert(photo:getRawMetadata('path')));
end
Above code will help you out the selection of categlog with Adobe's LightRoom Plugin.

how to pass additional parametes to spider parse function in scrapy during web scraping

I am trying to pass additional information to the parse function but it is giving a type error.
TypeError: parse() got an unexpected keyword argument 'body'
i am unable to resolve this issue.
"""
return [scrapy.Request(url=website.search_url.format(prod), callback=self.parse,
cb_kwargs = {"body":website.body_xpath,"product_list":website.products_list_xpath,
"names":website.products_name_xpath,"selling_price":website.selling_price_xpath,
"market_price":website.market_price_xpath}) for website in websites for prod in modified_products]
def parse(self, response):
body = response.cb_kwargs.get("body")
product_list = response.cb_kwargs.get("product_list")
name = response.cb_kwargs.get("names")
selling_price = response.cb_kwargs.get("selling_price")
market_price = response.cb_kwargs.get("market_price")
"""
I forgot to write those names in parse function definition, after adding them i am getting the correct result. Thanks for having a look at it.
"""
return [scrapy.Request(url=website.search_url.format(prod), callback=self.parse,
cb_kwargs = dict(body = website.body_xpath, product_list = website.products_list_xpath,
name = website.products_name_xpath, selling_price = website.selling_price_xpath,
market_price = website.market_price_xpath)) for website in websites for prod in modified_products]
def parse(self, response, body, product_list, name, selling_price, market_price):
body = response.cb_kwargs["body"]
product_list = response.cb_kwargs["product_list"]
name_ = response.cb_kwargs["name"]
selling_price_ = response.cb_kwargs["selling_price"]
market_price_ = response.cb_kwargs["market_price"]
"""

Why JAX-WS generates wrapper for all method arguments?

I am trying to generate web service interface using jax-ws, but i am getting a methods with wrapper class for all arguments instead of arguments list. For example:
#SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
#WebResult(name = "ResendControlsToDmiResponse", targetNamespace = "http://tempuri.org/", partName = "parameters")
#WebMethod(operationName = "ResendControlsToDmi", action = "http://tempuri.org/ResendControlsToDmi")
#Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "2014-01-30T16:01:26.266+02:00")
public ResendControlsToDmiResponse resendControlsToDmi(
#WebParam(partName = "parameters", name = "ResendControlsToDmiData", targetNamespace = "http://tempuri.org/")
ResendControlsToDmiData parameters
);
Can't understand why it's happening and how to generate method with corredct signature.
There rules about the naming of the part elements as they related to the operation name. In your case, it looks like the operation is named resendControlsToDmi, but the incoming data part/element is named ResendControlsToDmiData. Remove the Data off the end of that and it may change. The response element is properly ResendControlsToDmiResponse.

Resources