Skip to content

Commit b69a1f6

Browse files
Adding Mapping table for OpenAPI to CDS Conversion( Import) (#1848)
Co-authored-by: Rene Jeglinsky <[email protected]>
1 parent a7bea18 commit b69a1f6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tools/apis/cds-import.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ const csn = await cds.import.from.openapi(OpenAPI_JSON_file)
6868
```
6969
<br>
7070

71+
[Learn more about OpenAPI to OData Mapping.](#openapi-to-cds-odata-csn-conversion-mapping){.learn-more}
72+
7173
## cds.import.from.asyncapi() {.method}
7274

7375
This API can be used to convert the AsyncAPI specification file (JSON) into CSN.
@@ -122,3 +124,32 @@ The following mapping is used during the import of an external service API, see
122124
| _Edm.DateTime<br>Precision : Second_ <sup>1</sup> | `cds.DateTime` + `@odata.Type:'Edm.DateTime'` + `@odata.Precision:0` |
123125

124126
<sup>1</sup> only OData V2
127+
128+
## OpenAPI to CDS (OData CSN) Conversion Mapping
129+
130+
| **OpenAPI** | **OData Equivalent** |
131+
|---------------------------------------------|--------------------------------------------------------------|
132+
| `info.title` | `serviceName`, `@Core.Description` |
133+
| `info.version` | `@Core.SchemaVersion` |
134+
| `info.description` | `@Core.LongDescription` |
135+
| `paths.{path}.{method}` | `function` (GET) or `action` (others) |
136+
| `tags[0]` | `@Common.Label` |
137+
| `summary` / `description` | `@Core.Description`, `@Core.LongDescription` |
138+
| `parameters[].in` | `@openapi.in` |
139+
| `parameters[].name` | Transformed param name + `@openapi.name` if needed |
140+
| `parameters[].required` | `@openapi.required` |
141+
| `parameters[].style`, `explode`, `allowReserved` | `@openapi.style`, `@openapi.explode`, `@openapi.allowReserved` |
142+
| `parameters[].default` | `default: { val: ... }` |
143+
| `parameters[].description` | `@description` |
144+
| `requestBody.content.application/json.schema` | `params.body` |
145+
| `requestBody.$ref` | Dereferenced and used |
146+
| `responses["2XX"].content.application/json` | `returns` |
147+
| `$ref` | `type` or `includes` |
148+
| `components.schemas` / `definitions` | Named `types` |
149+
| `enum` | `enum`, `@assert.range` |
150+
| `format: date/time/uuid/binary` | `cds.Date`, `cds.Time`, `cds.Timestamp`, `cds.UUID`, etc. |
151+
| `pattern` | `@assert.format` |
152+
| `allOf`, `anyOf`, `oneOf` | `@openapi.allOf`, `@openapi.anyOf`, `@openapi.oneOf` |
153+
| `example` / `examples[0]` | `@Core.Example.Value` |
154+
| `type: object` with `properties` | `elements` |
155+
| `required` (on properties) | `@mandatory` |

0 commit comments

Comments
 (0)