Your initial code already has the base setup. The api names would be accessible by replacing displayName
with apiName
in your code. So you can parse both property display name and api name by using the object type instead of the i m p l references:
import { MyObjectType } from "@foundry/ontology-api";
// ...
// get list of display names
Object.values(MyObjectType.properties).map(property => property.displayName);
// get list of api names
Object.values(MyObjectType.properties).map(property => property.apiName);
// or get both as an object pair
Object.values(MyObjectType.properties).map(property => ({
"apiName": property.apiName,
"displayName": property.displayName
}));
You can also do much more with that.