Skip to content

Commit

Permalink
feat: adds odata metadata to entity type
Browse files Browse the repository at this point in the history
  • Loading branch information
snebjorn committed Mar 29, 2020
1 parent 3a5b247 commit 6bb870d
Show file tree
Hide file tree
Showing 24 changed files with 9,432 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/csdl2openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,8 @@ module.exports.csdl2openapi = function (
const updName = allName + '-update';
const isKey = keyMap(type);
const required = Object.keys(isKey);
const allProperties = {};
const metadata = { '@odata.id':{ type: "string", readOnly: true }, '@odata.etag': { type: 'string', readOnly: true, example: "W/\"08D7D40891852C76\"" } };
const allProperties = { ...metadata };
const creProperties = {};
const updProperties = {};

Expand Down
17 changes: 17 additions & 0 deletions tools/V4-CSDL-to-OpenAPI.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,23 @@

<xsl:if test="$direct and ($baseproperties!='' or $hereproperties!='')">
<xsl:text>,"properties":{</xsl:text>
<!-- odata entity metadata properties -->
<xsl:if test="not($suffix) and local-name($structuredType)='EntityType'">
<xsl:choose>
<xsl:when test="$odata-version='2.0'">
<xsl:text>"__metadata":{
"type":"object",
"readOnly":true,
"description":"This name/value pair is not data, but instead, specifies the metadata for the EntityType instance that the JSON object represents.",
"properties":{"id":{"type":"string"},"uri":{"type":"string"},"type":{"type":"string"},"etag":{"type":"string","example":"W/\"time(123456789)\""}}
},
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>"@odata.id":{"type":"string","readOnly":true},"@odata.etag":{"type":"string","readOnly":true,"example":"W/\"08D7D40891852C76\""},</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>

<xsl:if test="not($direct)">
Expand Down
Loading

0 comments on commit 6bb870d

Please sign in to comment.