with swagger you can annotate your java beans as models. Ex:
@ApiModel(value="xyz")
public class object1 {
@ApiModelProperty(name = "property1")
private String abc;
}
I want to load the strings "property1" & "xyz" from an external file in spring. any recommendations on how to do that?
Is that external file a swagger spec? If so, you could turn this around, and generate code from your spec. - Contract first.
For example you can use https://github.com/swagger-api/swagger-codegen to generate your model and even API interfaces (the operations) classes and then use them in your code.
I am using the springboot templates the swagger-codegen comes with.
java -jar swagger-codegen-cli.jar generate \
-i <input swagger spec> -l spring --library spring-boot
It also has options for specifying the package names of the generated code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.