You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{
"description": "A simple string response",
"schema": {
"type": "string"
},
"headers": {
"X-Rate-Limit-Limit": {
"description": "The number of allowed requests in the current period",
"type": "integer"
},
"X-Rate-Limit-Remaining": {
"description": "The number of remaining requests in the current period",
"type": "integer"
},
"X-Rate-Limit-Reset": {
"description": "The number of seconds left in the current period",
"type": "integer"
}
}
}
Notice that headers is not an array but an object which consists of several objects.
One way of solving this is to remove headers property from this class and introduce vendorExtensions property. So I could do something like this:
public class BaseHeaders
{
[JsonProperty("X-Rate-Limit-Limit")]
public Header XRateLimitLimit { get; set; }
[JsonProperty("X-Rate-Limit-Remaining")]
public Header XRateLimitRemaining { get; set; }
[JsonProperty("X-Rate-Limit-Reset")]
public Header XRateLimitReset { get; set; }
}
BaseHeaders headers = new BaseHeaders();
headers.XRateLimitLimit = new Header()
{
description = "Maximum number of requests permitted per minute",
type = "integer"
};
headers.XRateLimitRemaining = new Header()
{
description = "Remaining number of requests",
type = "integer"
};
headers.XRateLimitReset = new Header()
{
description = "Time in epoch seconds when limit will be reset",
type = "integer"
};
response.vendorExtensions.Add("headers", headers);
Now this is really ugly solution but it would be nice if headers could be a dictionary type.
The text was updated successfully, but these errors were encountered:
Class response looks like this:
When this is serialized to json it does not comply with Swagger spec 2.0.
As per swagger 2.0, https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md
Response with headers:
{
"description": "A simple string response",
"schema": {
"type": "string"
},
"headers": {
"X-Rate-Limit-Limit": {
"description": "The number of allowed requests in the current period",
"type": "integer"
},
"X-Rate-Limit-Remaining": {
"description": "The number of remaining requests in the current period",
"type": "integer"
},
"X-Rate-Limit-Reset": {
"description": "The number of seconds left in the current period",
"type": "integer"
}
}
}
Notice that headers is not an array but an object which consists of several objects.
One way of solving this is to remove headers property from this class and introduce vendorExtensions property. So I could do something like this:
Now this is really ugly solution but it would be nice if headers could be a dictionary type.
The text was updated successfully, but these errors were encountered: