Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-114482

Error generating API with tags not defined as schemas

    Details

      Description

      Executing REST Builder with an OpenAPI yaml file which includes some tags that are not including as schema in the Components Object causes an error in the API generation

      Steps to reproduce it:

      1. Create a new module with the attached YAML files (modifying configuration if needed).
      2. Execute
        gw buildRest

         
        Result: Exception is thrown

        may 28, 2020 8:57:34 AM freemarker.log._JULLoggerFactory$JULLogger error
        GRAVE: Error executing FreeMarker template
        FreeMarker template error:
        The following has evaluated to null or missing:
        ==> freeMarkerTool.getJavaDataType(configYAML, openAPIYAML, schemaName)  [in template "com/liferay/portal/tools/rest/builder/dependencies/base_resource_test_case.ftl" at line 1793, column 71]----
        Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
        --------
        FTL stack trace ("~" means nesting-related):
        	- Failed at: ${freeMarkerTool.getJavaDataType(conf...  [in template "com/liferay/portal/tools/rest/builder/dependencies/base_resource_test_case.ftl" at line 1793, column 69]
        ----Java stack trace (for programmers):
        ----
        freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
        	at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)
        	at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:467)
        	at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:389)
        	at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:358)
        	at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:100)
        	at freemarker.core.DollarVariable.accept(DollarVariable.java:63)
        	at freemarker.core.Environment.visit(Environment.java:330)
        	at freemarker.core.Environment.visit(Environment.java:336)
        	at freemarker.core.Environment.process(Environment.java:309)
        	at freemarker.template.Template.process(Template.java:384)
        	at com.liferay.portal.tools.rest.builder.internal.freemarker.FreeMarker.processTemplate(FreeMarker.java:60)
        	at com.liferay.portal.tools.rest.builder.internal.freemarker.util.FreeMarkerUtil.processTemplate(FreeMarkerUtil.java:32)
        	at com.liferay.portal.tools.rest.builder.RESTBuilder._createBaseResourceTestCaseFile(RESTBuilder.java:490)
        	at com.liferay.portal.tools.rest.builder.RESTBuilder.build(RESTBuilder.java:300)
        	at com.liferay.portal.tools.rest.builder.RESTBuilder.main(RESTBuilder.java:115)Exception in thread "main" java.lang.RuntimeException: Error generating REST API
        The following has evaluated to null or missing:
        ==> freeMarkerTool.getJavaDataType(configYAML, openAPIYAML, schemaName)  [in template "com/liferay/portal/tools/rest/builder/dependencies/base_resource_test_case.ftl" at line 1793, column 71]----
        Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
        --------
        FTL stack trace ("~" means nesting-related):
        	- Failed at: ${freeMarkerTool.getJavaDataType(conf...  [in template "com/liferay/portal/tools/rest/builder/dependencies/base_resource_test_case.ftl" at line 1793, column 69]
        ----
        	at com.liferay.portal.tools.rest.builder.RESTBuilder.main(RESTBuilder.java:125)
        FAILURE: Build failed with an exception.
        

        Expected Result: Ignore the tag or throw a controlled error that allows to identify the root cause

        Attachments

        1. rest-config.yaml
          0.3 kB
          Javier de Arcos Velilla
        2. rest-openapi.yaml
          4 kB
          Javier de Arcos Velilla

          Activity

            People

            Assignee:
            manoel.cyreno Manoel Cyreno
            Reporter:
            javier.dearcos Javier de Arcos Velilla
            Participants of an Issue:
            Recent user:
            Yunlin "Steven" Sun
            Engineering Assignee:
            Javier Gamarra
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 21 weeks, 6 days ago

                Packages

                Version Package
                7.0.X
                7.1.10 DXP FP19
                7.1.10.5 SP5
                7.1.X
                7.2.10 DXP FP7
                7.2.X
                7.3.3 CE GA4
                7.3.4 CE GA5
                7.3.10 DXP GA1
                Master