简体   繁体   English

从 LoopBack.io 中的 model 的字段中检索 ENUMS?

[英]Retrieving ENUMS from a field of a model in LoopBack.io?

So given a model in loopback, containing a field (for example) "fruits" with enum value ["apple", "banana", "pear"].因此,在环回中给定一个 model,其中包含一个字段(例如)“fruits”,其枚举值为 [“apple”、“banana”、“pear”]。 Is there a loopback method I can use to retrieve the enum values of this particular model which I can then later use in let's say a front end application?是否有一种环回方法可以用来检索这个特定 model 的枚举值,然后我可以在假设前端应用程序中使用它?

I assume that you are using @property({jsonSchema}) to define the enums.我假设您使用 @property({jsonSchema}) 来定义枚举。 If you're using a code generator to generate front-end code based on your app's openapi.json file, the code generator may do this for you.如果您使用代码生成器根据应用的 openapi.json 文件生成前端代码,代码生成器可能会为您执行此操作。 I use @openapitools/openapi-generator-cli and it does.我使用 @openapitools/openapi-generator-cli 并且确实如此。 Do you need access to the enums in loopback code?您是否需要访问环回代码中的枚举?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM