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

Unable to use external schema references

Details

    Description

      Description:

      When defining a schema inside the rest-openapi.yaml file it is possible to make references to external schemas as defined by other rest-openapi.yaml files external to the module. An example of that can be found in the headless-admin-content-impl:

      components:
          schemas:
              DisplayPageTemplate:
                  description:
                Represents a Display Page Template that has fields and is tied to   a content type
            properties:
                ...
                creator:
                    allOf:
                        - $ref: "../../headless-delivery/headless-delivery-impl/rest-openapi.yaml#Creator"
                description:
                    The Display Page Template's creator.
                readOnly: true
      ...

      The rest-opeapi.yaml  of the headless-admin-content-impl: refers to a schema described inside the headless-delivery-impl/rest-openapi.yaml module.

      Bug Description:

      When creating a rest-openapi.yaml file containing only schema definition it is not possible to refer to externally defined schemas. See attached files for a complete example.

      Context description: REST builder can be used to prepare DTO objects to be used with the Batch Import/Export framework, in this case a user is required to provide schema definitions only and not any path or other REST specific details

      Expected result

      Running the buildREST command against the provided rest-openapi file containing references to externally defined schemas I expect my DTOs to be created successfully.

      Actual result

      **The process fails with an NPE error:

      SEVERE: Error executing FreeMarker template
      FreeMarker template error:
      Java method "com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool.getDTOProperties(com.liferay.portal.tools.rest.builder.internal.yaml.config.ConfigYAML, com.liferay.portal.tools.rest.builder.internal.yaml.openapi.OpenAPIYAML, com.liferay.portal.tools.rest.builder.internal.yaml.openapi.Schema)" threw an exception when invoked on com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool object "com.liferay.portal.tools.rest[email protected]"; see cause exception in the Java stack trace.
      
      
      ----
      FTL stack trace ("~" means nesting-related):
      	- Failed at: properties = freeMarkerTool.getDTOPro...  [in template "com/liferay/portal/tools/rest/builder/dependencies/dto.ftl" at line 129, column 17]
      ----
      
      
      Java stack trace (for programmers):
      ----
      freemarker.core._TemplateModelException: [... Exception message was already printed; see it above ...]
      	at freemarker.ext.beans._MethodUtil.newInvocationTemplateModelException(_MethodUtil.java:289)
      	at freemarker.ext.beans._MethodUtil.newInvocationTemplateModelException(_MethodUtil.java:261)
      	at freemarker.ext.beans.OverloadedMethodsModel.exec(OverloadedMethodsModel.java:65)
      	at freemarker.core.MethodCall._eval(MethodCall.java:65)
      	at freemarker.core.Expression.eval(Expression.java:83)
      	at freemarker.core.Assignment.accept(Assignment.java:134)
      	at freemarker.core.Environment.visit(Environment.java:330)
      	at freemarker.core.Environment.visit(Environment.java:336)
      	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._createDTOFile(RESTBuilder.java:797)
      	at com.liferay.portal.tools.rest.builder.RESTBuilder.build(RESTBuilder.java:290)
      	at com.liferay.portal.tools.rest.builder.RESTBuilder.main(RESTBuilder.java:116)
      Caused by: java.lang.NullPointerException
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.parser.util.OpenAPIParserUtil.getArrayClassName(OpenAPIParserUtil.java:111)
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.parser.util.OpenAPIParserUtil.getJavaDataType(OpenAPIParserUtil.java:278)
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.parser.DTOOpenAPIParser._getPropertyType(DTOOpenAPIParser.java:249)
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.parser.DTOOpenAPIParser.getProperties(DTOOpenAPIParser.java:81)
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool.getDTOProperties(FreeMarkerTool.java:262)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1505)
      	at freemarker.ext.beans.ReflectionCallableMemberDescriptor.invokeMethod(ReflectionCallableMemberDescriptor.java:56)
      	at freemarker.ext.beans.MemberAndArguments.invokeMethod(MemberAndArguments.java:51)
      	at freemarker.ext.beans.OverloadedMethodsModel.exec(OverloadedMethodsModel.java:61)
      	... 13 more
      
      
      Exception in thread "main" java.lang.RuntimeException: Error generating REST API
      Java method "com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool.getDTOProperties(com.liferay.portal.tools.rest.builder.internal.yaml.config.ConfigYAML, com.liferay.portal.tools.rest.builder.internal.yaml.openapi.OpenAPIYAML, com.liferay.portal.tools.rest.builder.internal.yaml.openapi.Schema)" threw an exception when invoked on com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool object "com.liferay.portal.tools.rest[email protected]"; see cause exception in the Java stack trace.
      
      
      ----
      FTL stack trace ("~" means nesting-related):
      	- Failed at: properties = freeMarkerTool.getDTOPro...  [in template "com/liferay/portal/tools/rest/builder/dependencies/dto.ftl" at line 129, column 17]
      ----
      	at com.liferay.portal.tools.rest.builder.RESTBuilder.main(RESTBuilder.java:127)
      Caused by: freemarker.core._TemplateModelException: Java method "com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool.getDTOProperties(com.liferay.portal.tools.rest.builder.internal.yaml.config.ConfigYAML, com.liferay.portal.tools.rest.builder.internal.yaml.openapi.OpenAPIYAML, com.liferay.portal.tools.rest.builder.internal.yaml.openapi.Schema)" threw an exception when invoked on com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool object "com.liferay.portal.tools.rest[email protected]"; see cause exception in the Java stack trace.
      
      
      ----
      FTL stack trace ("~" means nesting-related):
      	- Failed at: properties = freeMarkerTool.getDTOPro...  [in template "com/liferay/portal/tools/rest/builder/dependencies/dto.ftl" at line 129, column 17]
      ----
      	at freemarker.ext.beans._MethodUtil.newInvocationTemplateModelException(_MethodUtil.java:289)
      	at freemarker.ext.beans._MethodUtil.newInvocationTemplateModelException(_MethodUtil.java:261)
      	at freemarker.ext.beans.OverloadedMethodsModel.exec(OverloadedMethodsModel.java:65)
      	at freemarker.core.MethodCall._eval(MethodCall.java:65)
      	at freemarker.core.Expression.eval(Expression.java:83)
      	at freemarker.core.Assignment.accept(Assignment.java:134)
      	at freemarker.core.Environment.visit(Environment.java:330)
      	at freemarker.core.Environment.visit(Environment.java:336)
      	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._createDTOFile(RESTBuilder.java:797)
      	at com.liferay.portal.tools.rest.builder.RESTBuilder.build(RESTBuilder.java:290)
      	at com.liferay.portal.tools.rest.builder.RESTBuilder.main(RESTBuilder.java:116)
      Caused by: java.lang.NullPointerException
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.parser.util.OpenAPIParserUtil.getArrayClassName(OpenAPIParserUtil.java:111)
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.parser.util.OpenAPIParserUtil.getJavaDataType(OpenAPIParserUtil.java:278)
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.parser.DTOOpenAPIParser._getPropertyType(DTOOpenAPIParser.java:249)
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.parser.DTOOpenAPIParser.getProperties(DTOOpenAPIParser.java:81)
      	at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool.getDTOProperties(FreeMarkerTool.java:262)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1505)
      	at freemarker.ext.beans.ReflectionCallableMemberDescriptor.invokeMethod(ReflectionCallableMemberDescriptor.java:56)
      	at freemarker.ext.beans.MemberAndArguments.invokeMethod(MemberAndArguments.java:51)
      	at freemarker.ext.beans.OverloadedMethodsModel.exec(OverloadedMethodsModel.java:61)
      	... 13 more
      
      
      > Task :apps:analytics:analytics-dxp-entities-exporter-api:baseline SKIPPED
      > Task :apps:analytics:analytics-dxp-entities-exporter-api:syncVersions
      
      
      
      
      FAILURE: Build failed with an exception.
      
      
      * What went wrong:
      Execution failed for task ':apps:analytics:analytics-dxp-entities-exporter-impl:buildREST'.
      > Process 'command '/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 

      Attachments

        Issue Links

          Activity

            People

              carlos.correa Carlos Correa
              riccardo.ferrari Riccardo Ferrari
              Kiyoshi Lee Kiyoshi Lee
              Carlos Correa Carlos Correa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                48 weeks, 6 days ago

                Packages

                  Version Package
                  7.0.X
                  7.1.X
                  7.2.X
                  7.3.X
                  7.4.3.23 CE GA23
                  Master