martin-dominguez / dev24restbuilder Goto Github PK
View Code? Open in Web Editor NEWAn example about how to use the Rest Builder tool. Created to show it in /dev/24
An example about how to use the Rest Builder tool. Created to show it in /dev/24
Hi Martin ,
i have tried to implement this in 7.3.0 ga1 but having a dependency issue. please check the below code.
Restbuilder-impl build.gradle File.
buildscript {
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.rest.builder", version: "1.0.114"
}
repositories {
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
}
}
apply plugin: "com.liferay.portal.tools.rest.builder"
dependencies {
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.0-ga1"
compileOnly project(":modules:RestBuilder-api")
}
I am able to Restbuild successfully . after adding "compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.0-ga1" this, still i have many things as not resolve . check below sceenshot.
Hi Martin,
Below is my yaml file. it looks good and no error with swager editor. But when i build using RESTBuild . it throws error of StringIndexOutofbound. Can you please look into it???
When i add array as response in path it throws this error..
info:
description: "An example about how to create an API usign the Rest Builder Tool"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
title: "LidereSalud RestBuilder API"
version: v1.0
openapi: 3.0.1
components:
schemas:
IsSpecialist:
description: "This is an example of an Object"
properties:
name:
description: "The Object Id"
type: string
description:
description: "The Object Name"
type: string
imageURL:
description: "URL"
type: string
imageDlId:
type: integer
imageData:
type: string
imageName:
type: string
groupId:
type: integer
companyId :
type: integer
localeCountry:
type: string
localeCode:
type: string
paths:
"/isSpecialist":
get:
description: "Gets a list of Objects"
operationId: getIsSpecialistObjectsPage
responses:
200:
description: ""
content:
application/json:
schema:
items:
$ref: "#/components/schemas/IsSpecialist"
type: array
application/xml:
schema:
items:
$ref: "#/components/schemas/IsSpecialist"
type: array
tags: ["IsSpecialist"]
post:
description: "Creates a new Object"
operationId: postIsSpecialistObject
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/IsSpecialist"
application/xml:
schema:
$ref: "#/components/schemas/IsSpecialist"
responses:
200:
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/IsSpecialist"
application/xml:
schema:
$ref: "#/components/schemas/IsSpecialist"
tags: ["IsSpecialist"]
"/isSpecialist/byLocalization":
get:
operationId: getIsSpecialistByLocale
description: "Get an Object by id"
parameters:
- in: query
name: locale_Country
required: true
schema:
type: string
- in: query
name: locale_Code
required: true
schema:
type: string
responses:
200:
description: ""
content:
application/json:
schema:
items:
$ref: "#/components/schemas/IsSpecialist"
type: array
application/xml:
schema:
items:
$ref: "#/components/schemas/IsSpecialist"
type: array
tags: ["IsSpecialist"]
"/isSpecialist/byGroupCompany":
get:
operationId: getIsSpecialist
description: "Get an Object by id"
parameters:
- in: query
name: group_Id
required: true
schema:
type: integer
- in: query
name: company_Id
required: true
schema:
type: integer
responses:
200:
description: ""
content:
application/json:
schema:
items:
$ref: "#/components/schemas/IsSpecialist"
type: array
application/xml:
schema:
items:
$ref: "#/components/schemas/IsSpecialist"
type: array
tags: ["IsSpecialist"]
Error ::
Writing D:\Liferay\Letest\Restbuilder-Graphql\Test\modules\RestBuilder-impl\rest-openapi.yaml
Oct 05, 2020 1:49:03 AM freemarker.log._JULLoggerFactory$JULLogger error
SEVERE: Error executing FreeMarker template
FreeMarker template error:
Java method "com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool.getGraphQLMethodJavadoc(com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.JavaMethodSignature, List, com.liferay.portal.tools.rest.builder.internal.yaml.openapi.OpenAPIYAML)" threw an exception when invoked on com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool object "com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool@4ff4357f"; see cause exception in the Java stack trace.
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:252)
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:77)
at freemarker.core.MethodCall._eval(MethodCall.java:65)
at freemarker.core.Expression.eval(Expression.java:83)
at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:100)
at freemarker.core.DollarVariable.accept(DollarVariable.java:63)
at freemarker.core.Environment.visit(Environment.java:366)
at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:317)
at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271)
at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:242)
at freemarker.core.Environment.visitIteratorBlock(Environment.java:642)
at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:107)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:93)
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._createGraphQLQueryFile(RESTBuilder.java:936)
at com.liferay.portal.tools.rest.builder.RESTBuilder.build(RESTBuilder.java:235)
at com.liferay.portal.tools.rest.builder.RESTBuilder.main(RESTBuilder.java:116)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1967)
at com.liferay.portal.vulcan.graphql.util.GraphQLNamingUtil.getGraphQLPropertyName(GraphQLNamingUtil.java:49)
at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool.getGraphQLPropertyName(FreeMarkerTool.java:365)
at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool._getGraphQLBody(FreeMarkerTool.java:856)
at com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool.getGraphQLMethodJavadoc(FreeMarkerTool.java:320)
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.SimpleMethodModel.exec(SimpleMethodModel.java:72)
... 20 more
Exception in thread "main" java.lang.RuntimeException: Error generating REST API
Java method "com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool.getGraphQLMethodJavadoc(com.liferay.portal.tools.rest.builder.internal.freemarker.tool.java.JavaMethodSignature, List, com.liferay.portal.tools.rest.builder.internal.yaml.openapi.OpenAPIYAML)" threw an exception when invoked on com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool object "com.liferay.portal.tools.rest.builder.internal.freemarker.tool.FreeMarkerTool@4ff4357f"; see cause exception in the Java stack trace.
at com.liferay.portal.tools.rest.builder.RESTBuilder.main(RESTBuilder.java:126)
Task :modules:RestBuilder-impl:buildREST FAILED
FAILURE: Build failed with an exception.
Process 'command 'C:\Program Files\Java\jdk1.8.0_241\bin\java.exe'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 24s
1 actionable task: 1 executed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.