Fix issue #29: Action responses not serialized the return type
This commit is contained in:
parent
37f49c4e3d
commit
db3c3e886c
|
@ -94,7 +94,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
|
||||
OpenApiResponses responses = new OpenApiResponses();
|
||||
|
||||
if (operation.IsAction())
|
||||
if (operation.IsAction() && operation.ReturnType == null)
|
||||
{
|
||||
responses.Add(Constants.StatusCode204, Constants.StatusCode204.GetResponse());
|
||||
}
|
||||
|
|
|
@ -181,9 +181,10 @@ namespace Microsoft.OpenApi.OData.Generator.Tests
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("ShareTrip", false)]
|
||||
[InlineData("ResetDataSource", true)]
|
||||
public void CreateResponseForEdmActionReturnCorrectResponses(string actionName, bool isActionImport)
|
||||
[InlineData("ShareTrip", false, "204")]
|
||||
[InlineData("ResetDataSource", true, "204")]
|
||||
[InlineData("GetPeersForTrip", false, "200")]
|
||||
public void CreateResponseForEdmActionReturnCorrectResponses(string actionName, bool isActionImport, string responseCode)
|
||||
{
|
||||
// Arrange
|
||||
IEdmModel model = EdmModelHelper.TripServiceModel;
|
||||
|
@ -208,7 +209,7 @@ namespace Microsoft.OpenApi.OData.Generator.Tests
|
|||
Assert.NotNull(responses);
|
||||
Assert.NotEmpty(responses);
|
||||
Assert.Equal(2, responses.Count);
|
||||
Assert.Equal(new string[] { "204", "default" }, responses.Select(r => r.Key));
|
||||
Assert.Equal(new string[] { responseCode, "default" }, responses.Select(r => r.Key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,12 @@
|
|||
<Parameter Name="userName" Type="Edm.String" Nullable="false" Unicode="false" />
|
||||
<Parameter Name="tripId" Type="Edm.Int32" Nullable="false" />
|
||||
</Action>
|
||||
<Action Name="GetPeersForTrip" IsBound="true">
|
||||
<Parameter Name="personInstance" Type="Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" />
|
||||
<Parameter Name="userName" Type="Edm.String" Nullable="false" Unicode="false" />
|
||||
<Parameter Name="tripId" Type="Edm.Int32" Nullable="false" />
|
||||
<ReturnType Type="Collection(Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person)" />
|
||||
</Action>
|
||||
<EntityContainer Name="Container">
|
||||
<EntitySet Name="People" EntityType="Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person">
|
||||
<NavigationPropertyBinding Path="Friends" Target="People" />
|
||||
|
|
|
@ -1153,6 +1153,61 @@
|
|||
"x-ms-docs-operation-type": "function"
|
||||
}
|
||||
},
|
||||
"/Me/Microsoft.OData.Service.Sample.TrippinInMemory.Models.GetPeersForTrip": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Me.Actions"
|
||||
],
|
||||
"summary": "Invoke action GetPeersForTrip",
|
||||
"operationId": "Me.GetPeersForTrip",
|
||||
"requestBody": {
|
||||
"description": "Action parameters",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userName": {
|
||||
"type": "string"
|
||||
},
|
||||
"tripId": {
|
||||
"maximum": 2147483647,
|
||||
"minimum": -2147483648,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person"
|
||||
}
|
||||
],
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"$ref": "#/components/responses/error"
|
||||
}
|
||||
},
|
||||
"x-ms-docs-operation-type": "action"
|
||||
}
|
||||
},
|
||||
"/Me/Microsoft.OData.Service.Sample.TrippinInMemory.Models.ShareTrip": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
@ -2234,6 +2289,73 @@
|
|||
"x-ms-docs-operation-type": "function"
|
||||
}
|
||||
},
|
||||
"/NewComePeople/{UserName}/Microsoft.OData.Service.Sample.TrippinInMemory.Models.GetPeersForTrip": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"NewComePeople.Actions"
|
||||
],
|
||||
"summary": "Invoke action GetPeersForTrip",
|
||||
"operationId": "NewComePeople.GetPeersForTrip",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "UserName",
|
||||
"in": "path",
|
||||
"description": "key: UserName",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-ms-docs-key-type": "Person"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "Action parameters",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userName": {
|
||||
"type": "string"
|
||||
},
|
||||
"tripId": {
|
||||
"maximum": 2147483647,
|
||||
"minimum": -2147483648,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person"
|
||||
}
|
||||
],
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"$ref": "#/components/responses/error"
|
||||
}
|
||||
},
|
||||
"x-ms-docs-operation-type": "action"
|
||||
}
|
||||
},
|
||||
"/NewComePeople/{UserName}/Microsoft.OData.Service.Sample.TrippinInMemory.Models.ShareTrip": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
@ -3367,6 +3489,73 @@
|
|||
"x-ms-docs-operation-type": "function"
|
||||
}
|
||||
},
|
||||
"/People/{UserName}/Microsoft.OData.Service.Sample.TrippinInMemory.Models.GetPeersForTrip": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"People.Actions"
|
||||
],
|
||||
"summary": "Invoke action GetPeersForTrip",
|
||||
"operationId": "People.GetPeersForTrip",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "UserName",
|
||||
"in": "path",
|
||||
"description": "key: UserName",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-ms-docs-key-type": "Person"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "Action parameters",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userName": {
|
||||
"type": "string"
|
||||
},
|
||||
"tripId": {
|
||||
"maximum": 2147483647,
|
||||
"minimum": -2147483648,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person"
|
||||
}
|
||||
],
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"$ref": "#/components/responses/error"
|
||||
}
|
||||
},
|
||||
"x-ms-docs-operation-type": "action"
|
||||
}
|
||||
},
|
||||
"/People/{UserName}/Microsoft.OData.Service.Sample.TrippinInMemory.Models.ShareTrip": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
|
|
@ -769,6 +769,41 @@ paths:
|
|||
default:
|
||||
$ref: '#/components/responses/error'
|
||||
x-ms-docs-operation-type: function
|
||||
/Me/Microsoft.OData.Service.Sample.TrippinInMemory.Models.GetPeersForTrip:
|
||||
post:
|
||||
tags:
|
||||
- Me.Actions
|
||||
summary: Invoke action GetPeersForTrip
|
||||
operationId: Me.GetPeersForTrip
|
||||
requestBody:
|
||||
description: Action parameters
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
userName:
|
||||
type: string
|
||||
tripId:
|
||||
maximum: 2147483647
|
||||
minimum: -2147483648
|
||||
type: integer
|
||||
format: int32
|
||||
required: true
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
anyOf:
|
||||
- $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person'
|
||||
nullable: true
|
||||
default:
|
||||
$ref: '#/components/responses/error'
|
||||
x-ms-docs-operation-type: action
|
||||
/Me/Microsoft.OData.Service.Sample.TrippinInMemory.Models.ShareTrip:
|
||||
post:
|
||||
tags:
|
||||
|
@ -1521,6 +1556,49 @@ paths:
|
|||
default:
|
||||
$ref: '#/components/responses/error'
|
||||
x-ms-docs-operation-type: function
|
||||
'/NewComePeople/{UserName}/Microsoft.OData.Service.Sample.TrippinInMemory.Models.GetPeersForTrip':
|
||||
post:
|
||||
tags:
|
||||
- NewComePeople.Actions
|
||||
summary: Invoke action GetPeersForTrip
|
||||
operationId: NewComePeople.GetPeersForTrip
|
||||
parameters:
|
||||
- name: UserName
|
||||
in: path
|
||||
description: 'key: UserName'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
x-ms-docs-key-type: Person
|
||||
requestBody:
|
||||
description: Action parameters
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
userName:
|
||||
type: string
|
||||
tripId:
|
||||
maximum: 2147483647
|
||||
minimum: -2147483648
|
||||
type: integer
|
||||
format: int32
|
||||
required: true
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
anyOf:
|
||||
- $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person'
|
||||
nullable: true
|
||||
default:
|
||||
$ref: '#/components/responses/error'
|
||||
x-ms-docs-operation-type: action
|
||||
'/NewComePeople/{UserName}/Microsoft.OData.Service.Sample.TrippinInMemory.Models.ShareTrip':
|
||||
post:
|
||||
tags:
|
||||
|
@ -2309,6 +2387,49 @@ paths:
|
|||
default:
|
||||
$ref: '#/components/responses/error'
|
||||
x-ms-docs-operation-type: function
|
||||
'/People/{UserName}/Microsoft.OData.Service.Sample.TrippinInMemory.Models.GetPeersForTrip':
|
||||
post:
|
||||
tags:
|
||||
- People.Actions
|
||||
summary: Invoke action GetPeersForTrip
|
||||
operationId: People.GetPeersForTrip
|
||||
parameters:
|
||||
- name: UserName
|
||||
in: path
|
||||
description: 'key: UserName'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
x-ms-docs-key-type: Person
|
||||
requestBody:
|
||||
description: Action parameters
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
userName:
|
||||
type: string
|
||||
tripId:
|
||||
maximum: 2147483647
|
||||
minimum: -2147483648
|
||||
type: integer
|
||||
format: int32
|
||||
required: true
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
anyOf:
|
||||
- $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person'
|
||||
nullable: true
|
||||
default:
|
||||
$ref: '#/components/responses/error'
|
||||
x-ms-docs-operation-type: action
|
||||
'/People/{UserName}/Microsoft.OData.Service.Sample.TrippinInMemory.Models.ShareTrip':
|
||||
post:
|
||||
tags:
|
||||
|
|
Loading…
Reference in a new issue