Forum Discussion

trumpvsbiden's avatar
trumpvsbiden
Frequent Visitor
4 years ago

Unable to access custom tag

Hello Guys,

This question is for Swagger Codegen, In the info section of API Spec I added custom tag "x-EnableEureka: true."
If I am trying to access this custom tag in apiController.mustache as {{vendorExtensions.x-responseEntity}}.

Its printing noting.
How can I access the custom tag?

 

i have added both of these filed for reference the input API def ( see line number 6,7& 32 ) and apiController.mustache (line number 55 to 66). Only hard coded values  are getting printed. 

 

Can you please help to understand, why I am unable to access the custom tag and how can I do it?

  • Hello,

     

    Right now, there is not a way to access Info object vendor extensions from templates. I have created a PR to fix that https://github.com/swagger-api/swagger-codegen/pull/10557

     

    If you are using codegen as a dependency in your project, you could override method

    DefaultGenerator.configureSwaggerInfo

     for something like:

    protected void configureSwaggerInfo() {
    if (info.getVendorExtensions() != null && !info.getVendorExtensions().isEmpty()) {
    config.additionalProperties().put("info-extensions", info.getVendorExtensions());
    }
    }

     

  • Hello,

     

    Right now, there is not a way to access Info object vendor extensions from templates. I have created a PR to fix that https://github.com/swagger-api/swagger-codegen/pull/10557

     

    If you are using codegen as a dependency in your project, you could override method

    DefaultGenerator.configureSwaggerInfo

     for something like:

    protected void configureSwaggerInfo() {
    if (info.getVendorExtensions() != null && !info.getVendorExtensions().isEmpty()) {
    config.additionalProperties().put("info-extensions", info.getVendorExtensions());
    }
    }