I have a scheme Foo with the fields a, b and c. c is an array which is not returned when I do a GET /foos, but it is returned when I do GET /foos/{foo_id}.
How can I represent that with swagger scheme? (the c field being shown only when GETing a specific Foo)
Related
Recently, I am migrating Swagger from SpringFox to SpringDoc, and meeting an issue of handling object parameters.
For example, the object contains 3 attributes: A, B and C. In Swagger I can set A B C with values: a, b and c. I am wondering can I in some way use "a:b:c" as a path parameter.
I have checked the parameters serialization here: https://swagger.io/docs/specification/serialization/ But there is no styling like this: "a:b:c"
Is there any annotation or way to display mutually exclusive field in API model (JSON) correctly in swagger ?
eg. If I have following API model and I want to show field A and B are mutually exclusive e.g. Java class say AtoZ has following structure
class AtoZ {
String A;
String B;
#ApiModelProperty(value ="This is field C", required = true)
String C;
}
Let say field C is required as annotated above but field A and B are mutually exclusive i.e. only one of field is required/can exist. If both A and B are annotated as Optional (i.e. required =false) that will not enforce mutually exclusive constraint.
Wondering if there is any appropriate annotation in swagger which allow documenting this kind of structure in Swagger UI ?
I really liked the example and the code of this link Neo4j: Display all connected nodes and their parent in tree-like graph
but the thing is that as I managed it to my database it thrown me some warnings.
This feature is deprecated and will be removed in future versions.
Using 'length' on anything that is not a path is deprecated, please use 'size' instead
WITH REDUCE(s=[], i IN RANGE(0, LENGTH(np)-2, 1) | s + {p:np[i], c:np[i+1]}) AS cpairs
^
The provided property key is not in the database
One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is is: p)
RETURN ps.p, "parent of", ps.c;
^
The provided property key is not in the database
One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is is: c)
RETURN ps.p, "parent of", ps.c;
^
I fixed the first one by substituting the length with size...
What about the rest? since they're declared in previous lines?
Here's my version of code:
MATCH path=(n:Atomo {name:'Dema'})<-[:DAD_OF*]-()
WITH NODES(path) AS np
WITH REDUCE(s=[], i IN RANGE(0, SIZE(np)-2, 1) | s + {p:np[i], c:np[i+1]}) AS cpairs
UNWIND cpairs AS pairs
WITH DISTINCT pairs AS ps
RETURN ps.p, "parent of", ps.c;
I am trying to make a table, name given by the first arg of a function and assign a value to a key named by the second arg. For example
function myinsert(a, b)
a.b = 10
For example when I give args pencil and price, pencil table to be created and pencil.price to be 10. Or other args, lesson and grade, making lesson.grade = 10. But as I try this it gives that it can't index local a (number value). What should I do? Thanks a lot
You can use the loadstring function, which will evaluate arbitrary code in string
http://www.lua.org/pil/14.1.html
Example:
function myinsert(a, b)
f = loadstring(string.format("%s={}; %s.%s=10", a, a, b))
f()
You can use _G[a]={[b]=10} to create a global table whose name is stored in a. The name of field to receive 10 is stored in b.
For example:
a = "pencil"
b = "price"
_G[a]={[b]=10}
is the same as
pencil.price=10
The code works even if a or b are not really names, that is, they don't have to be strings.
I have nodes within a the graph with property pathway storing an array of of values ranging from
path:ko00030
path:ko00010
.
.
path:koXXXXX
As an example, (i'm going to post in the batch import format:https://github.com/jexp/batch-import/tree/20)
ko:string:koid name definition l:label pathway:string_array pathway.name:string_array
ko:K00001 E1.1.1.1, adh alcohol dehydrogenase [EC:1.1.1.1] ko path:ko00010|path:ko00071|path:ko00350|path:ko00625|path:ko00626|path:ko00641|path:ko00830
the subsequent nodes might have a different combination of pathway values.
How do i query using CYPHER to retrieve all nodes with path:ko00010 in pathway
the closest i've gotten is using the solution provided for a different problem:
How to check array property in neo4j?
match (n:ko)--cpd
Where has(n.pathway) and all ( m in n.pathway where m in ["path:ko00010"])
return n,cpd;
but here only nodes with pathways matching exactly to the list provided are returned.
ie. if i were to query path:ko00010 like in the example above, I'll only be able to retrieve nodes holding path:ko00010 as the only element in the pathway property and not nodes containing path:ko00010 as well as other path:koXXXXX
In your query the extension of the predicate ALL is all the values in the property array, meaning that your query will only return those cases where every value in the pathway property array are found in the literal array ["path:ko00010"]. If I understand you right you want the opposite, you want to test that all values in the literal array ["path:ko00010"] are found in the property array pathway. If that's indeed what you want you can just switch their places, your WHERE clause will then be
WHERE HAS(n.pathway) AND ALL (m IN ["path:ko00010"] WHERE m IN n.pathway)
It is not strictly correct to say that your query only matches cases where the array you ask for and the property array are exactly the same. You could have had more than one value in the literal array, something like ["path:ko00010","path:ko00020"], and nodes with only one one of those values in their pathway array would also have matched–as long as all values in the property array could be found in the literal array. Conversely, with the altered WHERE filter that I've suggested, the query will match any node that has all of the values of the literal array in their pathway property.
If you want to filter the matched patterns with an array of values where all of them have to be present, this is good. In your example you only use one value, however, and for those queries there is no reason to use an array and the ALL predicate. You can simply do
WHERE HAS(n.pathway) and "path:ko00010" IN n.pathway
If in some context you want to include results where any of a set of values are found in the pathway property array you can just switch from ALL to ANY
WHERE HAS(n.pathway) AND ANY (m IN ["path:ko00010","path:ko00020"] WHERE m IN n.pathway)
Also, you probably don't need to check for the presence of the pathway property, unless you have some special use for it you should be fine without the HAS(n.pathway).
And once you've got the queries working right, try to switch out literal strings and arrays for parameters!
WHERE {value} IN n.pathway
// or
WHERE ALL (m IN {value_array} WHERE m IN n.pathway)
// or
WHERE ANY (m IN {value_array} WHERE m IN n.pathway)