elasticio / odata2openapi

OData to OpenAPI Converter
https://www.elastic.io
MIT License
33 stars 23 forks source link

Collections of Entity Types are not correctly converted to JSONSchema #24

Closed jhorbulyk closed 6 years ago

jhorbulyk commented 6 years ago

Consider the metadata/TripPinServiceRW/$metadata) from OData's TripPin sample service/TripPinServiceRW/$metadata). It contains the person entity type which is as follows

<EntityType Name="Person" OpenType="true">
    <Key>
        <PropertyRef Name="UserName"/>
    </Key>
    <Property Name="UserName" Type="Edm.String" Nullable="false">
        <Annotation Term="Org.OData.Core.V1.Permissions">
            <EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember>
        </Annotation>
    </Property>
    <Property Name="FirstName" Type="Edm.String" Nullable="false"/>
    <Property Name="LastName" Type="Edm.String" Nullable="false"/>
    <Property Name="Emails" Type="Collection(Edm.String)"/>
    <Property Name="AddressInfo" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Location)"/>
    <Property Name="Gender" Type="Microsoft.OData.SampleService.Models.TripPin.PersonGender"/>
    <Property Name="Concurrency" Type="Edm.Int64" Nullable="false">
        <Annotation Term="Org.OData.Core.V1.Computed" Bool="true"/>
    </Property>
    <NavigationProperty Name="Friends" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Person)"/>
    <NavigationProperty Name="Trips" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Trip)" ContainsTarget="true"/>
    <NavigationProperty Name="Photo" Type="Microsoft.OData.SampleService.Models.TripPin.Photo"/>
</EntityType>

Observe that there is this definition, there is an AddressInfo property which is an Array/Collection of an entity type defined elsewhere in the metadata. I would expect the JSONSchema for the AddressInfo property to look like:

{
  "type": "array",
  "items": {
    "$ref": "#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location"
  }
}

Instead, we are provided

{
  "type": "object"
}
jhorbulyk commented 6 years ago

Fixed in #26 and published in v 1.3.0