-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Consider annotations in imported API specifications #471
Comments
Hi Marvin, thank you for bringing this up. {
definitions: {
'Get.Children_types.object': {
kind: 'type',
elements: {
objects: {
items: {
elements: {
object: {
elements: {
properties: {
elements: {
cmis_objectId: {
'@openapi.name': 'cmis:objectId',
elements: [Object: null prototype]
}
}
}
}
}
}
}
}
}
}
},
meta: { creator: 'CDS Compiler v5.4.2', flavor: 'inferred' },
'$version': '2.0'
} So the property in question is indeed this.on('READ', object, ({data}) => {
data['cmis:objectId']
}) then they'd be confronted with runtime errors. The intellisense is therefore correct. Best, |
Thank you for checking. What you wrote is true and is also my point why it might be necessary to create two individual types. Even though the CSN does contain This can also be seen in the case I described in the original message. When calling the API, the remote service does indeed return A workaround for this would be to use the openapi-generator with which the correct return type is exposed. |
Hi Marvin, we discussed your suggestion and came to the conclusion that this is not doable as of today. Best, |
Description
Im currently using an API to get object children from the SAP Document Management Service.
I imported the OpenAPI resources into my project via
cds import <path/to/file> --as cds
. Now, the specification (and also the object returned by an API call) includes object keys with special characters, e.g.cmis:objectId
. This is converted bycds import
tocmis_objectId
, which is also used as a basis by cds-typer. This results in wrong intellisense.The generated API .cds file include some
@openai
annotations with the correct name though. In the example case:So there is the "correct" information present. It would be great if cds-typer would provide these openapi names instead of the wrongfully converted ones.
Suggested Solution
Use the correct API names indicated by the annotations.
I must say I'm unsure if it must be the case to generate two sets of types here. I haven't had a use case yet, where I used the names in e.g. cds entities. It could be the case, that the cds types themselves would be wrongly generated (the real problem would be the poorly chosen names in the api) or that the cds types are expected as generated. In the latter case two sets of types are needed.
Alternatives
The only alternative I see here is to create the types individually, which would counteract the purpose of cds-typer...
Additional Context
No response
The text was updated successfully, but these errors were encountered: