Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVCSwagParam ptArray Bug #377

Open
st1gok opened this issue May 3, 2020 · 17 comments
Open

MVCSwagParam ptArray Bug #377

st1gok opened this issue May 3, 2020 · 17 comments
Assignees

Comments

@st1gok
Copy link

st1gok commented May 3, 2020

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"
]
}
}

@joaoduarte19
Copy link
Collaborator

I will check this behavior

@st1gok
Copy link
Author

st1gok commented May 3, 2020

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

@joaoduarte19
Copy link
Collaborator

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/

@joaoduarte19
Copy link
Collaborator

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?
image

Is working as expected

@st1gok
Copy link
Author

st1gok commented May 3, 2020

Would that be the JsonSchema of the SwaggerDoc example?

yes, if this object then working, but me need array objects

@st1gok
Copy link
Author

st1gok commented May 3, 2020

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/
image

@joaoduarte19
Copy link
Collaborator

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"
			}
		}
	}
}

@st1gok
Copy link
Author

st1gok commented May 3, 2020

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 #377 (comment) but this not worked

@joaoduarte19
Copy link
Collaborator

I think you're missing something. In my tests it is working correctly;
Untitled-1

See this attached sample. Enumerators and array of objects work correctly:
swaggerdoc.zip

@st1gok
Copy link
Author

st1gok commented May 3, 2020

Ok, I test tomorrow and answer

@st1gok
Copy link
Author

st1gok commented May 4, 2020

I think you're missing something. In my tests it is working correctly;
Untitled-1

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"
                ]
            }
   }

@joaoduarte19
Copy link
Collaborator

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.

@st1gok
Copy link
Author

st1gok commented May 4, 2020

Is it possible for now to implement this parameter through AJsonSchema?

@joaoduarte19
Copy link
Collaborator

I believe it is possible. However it is necessary to test to be sure of this.

@st1gok
Copy link
Author

st1gok commented May 4, 2020

I couldn’t do it (

@blitt001
Copy link

blitt001 commented Jan 4, 2021

What is the status of this problem ? We are facing similair problem now.

@joaoduarte19
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants