delphimvcframework
delphimvcframework copied to clipboard
MVCSwagParam ptArray Bug
Hi! I use RC6 and applied changes from fix https://github.com/danieleteti/delphimvcframework/issues/376
When you use MVCSwagParam(plQuery, 'types', 'types', ptArray, false,'','money,loading,unloading')
result in json: { "in": "query", "name": "types", "description": "types", "type": "array", "enum": [ "money", "loading", "unloading" ] }
but it should be: { "name": "types", "in": "query", "description": "types", "type": "array", "items": { "type": "string", "enum": [ "money", "loading", "unloading" ] } }
I will check this behavior
Also I have problem with [MVCSwagResponses(200, 'ok', INDEX_JSON_SCHEMA)] where INDEX_JSON_SCHEMA = '{' + sLineBreak + ' "type": "array",' + sLineBreak + ' "items": {' + sLineBreak + ' "type": "object",' + sLineBreak + ' "properties": {' + sLineBreak + ' "application": {' + sLineBreak + ' "type": "string",' + sLineBreak + ' "description": "Application Name"' + sLineBreak + ' },' + sLineBreak + ' "online": {' + sLineBreak + ' "type": "boolean",' + sLineBreak + ' "description": "Defines if the server is online"' + sLineBreak + ' },' + sLineBreak + ' "serverdatetime": {' + sLineBreak + ' "type": "string",' + sLineBreak + ' "description": "Current server time"' + sLineBreak + ' }' + sLineBreak + ' }' + sLineBreak + ' },' + sLineBreak + '}';
maybe these errors are related
Hi! I use RC6 and applied changes from fix #376
When you use MVCSwagParam(plQuery, 'types', 'types', ptArray, false,'','money,loading,unloading')
result in json: { "in": "query", "name": "types", "description": "types", "type": "array", "enum": [ "money", "loading", "unloading" ] }
but it should be: { "name": "types", "in": "query", "description": "types", "type": "array", "items": { "type": "string", "enum": [ "money", "loading", "unloading" ] } }
Using the last commit from dmvc I did these tests and when I define the parameter type as an array, the generated JsonSchema shows it as an array. However when you use enumerators the value of an enumerator cannot be an array. See https://swagger.io/docs/specification/2-0/enums/
Also I have problem with [MVCSwagResponses(200, 'ok', INDEX_JSON_SCHEMA)] where INDEX_JSON_SCHEMA = '{' + sLineBreak + ' "type": "array",' + sLineBreak + ' "items": {' + sLineBreak + ' "type": "object",' + sLineBreak + ' "properties": {' + sLineBreak + ' "application": {' + sLineBreak + ' "type": "string",' + sLineBreak + ' "description": "Application Name"' + sLineBreak + ' },' + sLineBreak + ' "online": {' + sLineBreak + ' "type": "boolean",' + sLineBreak + ' "description": "Defines if the server is online"' + sLineBreak + ' },' + sLineBreak + ' "serverdatetime": {' + sLineBreak + ' "type": "string",' + sLineBreak + ' "description": "Current server time"' + sLineBreak + ' }' + sLineBreak + ' }' + sLineBreak + ' },' + sLineBreak + '}';
maybe these errors are related
Would that be the JsonSchema of the SwaggerDoc example?

Is working as expected
Would that be the JsonSchema of the SwaggerDoc example?
yes, if this object then working, but me need array objects
Hi! I use RC6 and applied changes from fix #376 When you use MVCSwagParam(plQuery, 'types', 'types', ptArray, false,'','money,loading,unloading') result in json: { "in": "query", "name": "types", "description": "types", "type": "array", "enum": [ "money", "loading", "unloading" ] } but it should be: { "name": "types", "in": "query", "description": "types", "type": "array", "items": { "type": "string", "enum": [ "money", "loading", "unloading" ] } }
Using the last commit from dmvc I did these tests and when I define the parameter type as an array, the generated JsonSchema shows it as an array. However when you use enumerators the value of an enumerator cannot be an array. See https://swagger.io/docs/specification/2-0/enums/
I tested this in editor.swagger.io
array may contain enum
https://swagger.io/docs/specification/2-0/describing-parameters/

yes, if this object then working, but me need array objects
This object represented as an array should look like this:
{
"type": "array",
"items": {
"type": "object",
"properties": {
"application": {
"type": "string",
"description": "Application Name"
},
"online": {
"type": "boolean",
"description": "Defines if the server is online"
},
"serverdatetime": {
"type": "string",
"description": "Current server time"
}
}
}
}
yes, if this object then working, but me need array objects
This object represented as an array should look like this:
{ "type": "array", "items": { "type": "object", "properties": { "application": { "type": "string", "description": "Application Name" }, "online": { "type": "boolean", "description": "Defines if the server is online" }, "serverdatetime": { "type": "string", "description": "Current server time" } } } }
I agree see my post https://github.com/danieleteti/delphimvcframework/issues/377#issuecomment-623094609 but this not worked
I think you're missing something. In my tests it is working correctly;

See this attached sample. Enumerators and array of objects work correctly: swaggerdoc.zip
Ok, I test tomorrow and answer
I think you're missing something. In my tests it is working correctly;
See this attached sample. Enumerators and array of objects work correctly: swaggerdoc.zip
Yes, array of objects work correctly, I have extra comma in my example. Enums work is single, but not array of enum. Need next result :
{
"name": "types",
"in": "query",
"description": "types",
"required": false,
"type": "array",
"items": {
"type": "string",
"enum": [
"money",
"loading",
"unloading"
]
}
}
Enums work is single, but not array of enum.
Indeed, swagger middleware does not support enumerators as an array. We will implement this functionality soon.
Is it possible for now to implement this parameter through AJsonSchema?
I believe it is possible. However it is necessary to test to be sure of this.
I couldn’t do it (
What is the status of this problem ? We are facing similair problem now.
What is the status of this problem ? We are facing similair problem now.
When we add support for OpenAPI 3.0 we intend to correct this problem. What problem are you having? You can describe it, so we can try to solve it.