Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
RAGO - RAG OpenAPI Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
RAGO - RAG OpenAPI Framework
Merge requests
!1
Tests/openapi generator
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Tests/openapi generator
tests/openapi-generator
into
main
Overview
0
Commits
50
Pipelines
17
Changes
1
Merged
Johannes Mey
requested to merge
tests/openapi-generator
into
main
3 years ago
Overview
0
Commits
50
Pipelines
17
Changes
1
Expand
Fixes
#1 (closed)
Edited
3 years ago
by
Johannes Mey
0
0
Merge request reports
Viewing commit
978ce03d
Prev
Next
Show latest version
1 file
+
130
−
125
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
978ce03d
edit Parser.jrag (~ ComponentsObject)
· 978ce03d
Jueun Park
authored
3 years ago
src/main/jastadd/Parser.jrag
+
130
−
125
Options
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.*;
import io.swagger.v3.oas.models.servers.*;
import io.swagger.v3.oas.models.Components;
aspect Parser {
@@ -41,150 +44,152 @@ aspect Parser {
return openapi;
}
public static InfoObject InfoObject.parseInfo(Info info, Map<Object, ASTNode> map) {
InfoObject infoObject = new InfoObject();
if (info.getTitle() != null)
infoObject.setTitle(info.getTitle());
if (info.getVersion() != null)
infoObject.setVersion(info.getVersion());
if (info.getDescription() != null)
infoObject.setDescription(info.getDescription());
if (info.getTermsOfService() != null)
infoObject.setTermsOfService(info.getTermsOfService());
if (info.getContact() != null)
infoObject.setContactObject(ContactObject.parseContact(info.getContact(), map));
if (info.getLicense() != null)
infoObject.setLicenseObject(LicenseObject.parseLicense(info.getLicense(), map));
if (info.getExtensions() != null) {
for (String key : info.getExtensions().keySet())
infoObject.addExtension(new Extension(key, info.getExtensions().get(key)));
}
map.put(info, infoObject);
return infoObject;
}
public static InfoObject InfoObject.parseInfo(Info info) {
InfoObject infoObject = new InfoObject();
if (info.getTitle() != null)
infoObject.setTitle(info.getTitle());
if (info.getVersion() != null)
infoObject.setVersion(info.getVersion());
if (info.getDescription() != null)
infoObject.setDescription(info.getDescription());
if (info.getTermsOfService() != null)
infoObject.setTermsOfService(info.getTermsOfService());
if (info.getContact() != null)
infoObject.set_impl_c(ContactObject.parseContact(info.getContact()));
if (info.getLicense() != null)
infoObject.set_impl_l(LicenseObject.parseLicense(info.getLicense()));
if (info.getExtensions() != null) {
for (String key : info.getExtensions().keySet())
infoObject.addEx(new Extension(key, info.getExtensions().get(key)));
}
public static ContactObject ContactObject.parseContact(Contact contact, Map<Object, ASTNode> map){
ContactObject contactObject = new ContactObject();
/* 3.1.0 features
if (info.getSummary != null) ...
*/
if (contact.getName() != null)
contactObject.setName(contact.getName());
if (contact.getUrl() != null)
contactObject.setUrl(contact.getUrl());
if (contact.getEmail() != null)
contactObject.setEmail(contact.getEmail());
if (contact.getExtensions() != null) {
for (String key : contact.getExtensions().keySet())
contactObject.addExtension(new Extension(key, contact.getExtensions().get(key)));
}
return infoObject;
}
public static ContactObject ContactObject.parseContact(Contact contact){
ContactObject contactObject = new ContactObject();
if (contact.getName() != null)
contactObject.setName(contact.getName());
if (contact.getUrl() != null)
contactObject.setUrl(contact.getUrl());
if (contact.getEmail() != null)
contactObject.setEmail(contact.getEmail());
if (contact.getExtensions() != null) {
for (String key : contact.getExtensions().keySet())
contactObject.addEx(new Extension(key, contact.getExtensions().get(key)));
}
map.put(contact, contactObject);
return contactObject;
return contactObject;
}
public static LicenseObject LicenseObject.parseLicense(License license
, Map<Object, ASTNode> map
){
LicenseObject licenseObject = new LicenseObject();
public static LicenseObject LicenseObject.parseLicense(License license){
LicenseObject licenseObject = new LicenseObject();
if (license.getName() != null)
licenseObject.setName(license.getName());
if (license.getUrl() != null)
licenseObject.setUrl(license.getUrl());
if (license.getExtensions() != null) {
for (String key : license.getExtensions().keySet())
licenseObject.addEx
tension
(new Extension(key, license.getExtensions().get(key)));
}
if (license.getName() != null)
licenseObject.setName(license.getName());
if (license.getUrl() != null)
licenseObject.setUrl(license.getUrl());
if (license.getExtensions() != null) {
for (String key : license.getExtensions().keySet())
licenseObject.addEx(new Extension(key, license.getExtensions().get(key)));
}
map.put(license, licenseObject);
return licenseObject;
/* 3.1.0 features
if (license.getIdentifier() != null) ...
*/
return licenseObject;
}
public static ServerObject ServerObject.parseServer(Server server
, Map<Object, ASTNode> map
){
ServerObject serverObject = new ServerObject();
public static ServerObject ServerObject.parseServer(Server server){
ServerObject serverObject = new ServerObject();
if (server.getUrl() != null)
serverObject.setUrl(server.getUrl());
if (server.getDescription() != null)
serverObject.setDescription(server.getDescription());
if (server.getVariables() != null) {
for (String key : server.getVariables().keySet())
serverObject.addS
erverVariablesTuple
(new ServerVariablesTuple(key, ServerVariableObject.parseServerVariable(server.getVariable(key)
, map
)));
}
if (server.getExtensions() != null) {
for (String key : server.getExtensions().keySet())
serverObject.addEx
tension
(new Extension(key, server.getExtensions().get(key)));
}
if (server.getUrl() != null)
serverObject.setUrl(server.getUrl());
if (server.getDescription() != null)
serverObject.setDescription(server.getDescription());
if (server.getVariables() != null) {
for (String key : server.getVariables().keySet())
serverObject.addS
t
(new ServerVariablesTuple(key, ServerVariableObject.parseServerVariable(server.getVariable
s().get
(key))));
}
if (server.getExtensions() != null) {
for (String key : server.getExtensions().keySet())
serverObject.addEx(new Extension(key, server.getExtensions().get(key)));
}
map.put(server, serverObject);
return serverObject;
return serverObject;
}
public static ServerVariableObject ServerVariableObject.parseServerVariable(ServerVariable serverVariable
, Map<Object, ASTNode> map
){
ServerVariableObject serverVariableObject = new ServerVariableObject();
public static ServerVariableObject ServerVariableObject.parseServerVariable(ServerVariable serverVariable){
ServerVariableObject serverVariableObject = new ServerVariableObject();
if (serverVariable.getDefault() != null)
serverVariableObject.setDefault(serverVariable.getDefault());
if (serverVariable.getDescription() != null)
serverVariableObject.setDescription(serverVariable.getDescription());
if (serverVariable.getEnum
s
() !=
null
) {
for (String e : serverVariable.getEnum
s
())
serverVariableObject.addE
num
(new Enum(e));
}
if (serverVariable.getExtensions() != null) {
for (String key : serverVariable.getExtensions().keySet())
serverVariableObject.addEx
tension
(new Extension(key, serverVariable.getExtensions().get(key)));
}
if (serverVariable.getDefault() != null)
serverVariableObject.setDefault(serverVariable.getDefault());
if (serverVariable.getDescription() != null)
serverVariableObject.setDescription(serverVariable.getDescription());
if (serverVariable.getEnum
().size
() !=
0
) {
for (String e : serverVariable.getEnum())
serverVariableObject.addE(new Enum(e));
}
if (serverVariable.getExtensions() != null) {
for (String key : serverVariable.getExtensions().keySet())
serverVariableObject.addEx(new Extension(key, serverVariable.getExtensions().get(key)));
}
map.put(serverVariable, serverVariableObject);
return serverVariableObject;
return serverVariableObject;
}
public static ComponentsObject ComponentsObject.parseComponents(Components components
, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
ComponentsObject componentsObject = new ComponentsObject();
public static ComponentsObject ComponentsObject.parseComponents(Components components
)
{
ComponentsObject componentsObject = new ComponentsObject();
if (components.getSchemas() != null) {
for (String key : components.getSchemas().keySet())
componentsObject.addS
chemaTuple
(new SchemaTuple(key, SchemaOb.parseSchema(components.getSchema
(key), context, map
)));
}
if (components.getResponses() != null) {
for (String key : components.getResponses().keySet())
componentsObject.addR
esponseTuple
(new ResponseTuple(key, ResponseOb.parseResponse(components.getResponse
(key), context, map
)));
}
if (components.getParameters() != null) {
for (String key : components.getParameters().keySet())
componentsObject.addP
arameterTuple
(new ParameterTuple(key, ParameterOb.parseParameter(components.getParameter
(key), context, map
)));
}
if (components.getExamples() != null) {
for (String key : components.getExamples().keySet())
componentsObject.addE
xampleTuple
(new ExampleTuple(key, ExampleObject.parseExample(components.getExample
(key), context, map
)));
}
if (components.getRequestBodies() != null) {
for (String key : components.getRequestBodies().keySet())
componentsObject.addR
equestBodyTuple
(new RequestBodyTuple(key, RequestBodyOb.parseRequestBody(components.getRequestBod
y(key), context, map
)));
}
if (components.getHeaders() != null) {
for (String key : components.getHeaders().keySet())
componentsObject.addH
eaderTuple
(new HeaderTuple(key, HeaderOb.parseHeader(components.getHeader
(key), context, map
)));
}
if (components.getSecuritySchemes() != null) {
for (String key : components.getSecuritySchemes().keySet())
componentsObject.addS
ecuritySchemeTuple
(new SecuritySchemeTuple(key, SecuritySchemeOb.parseSecurityScheme(components.getSecurityScheme
(key), context, map
)));
}
if (components.getLinks() != null) {
for (String key : components.getLinks().keySet())
componentsObject.addL
inkTuple
(new LinkTuple(key, LinkOb.parseLink(components.getLink
(key), context, map
)));
}
if (components.getCallbacks() != null) {
for (String key : components.getCallbacks().keySet())
componentsObject.addC
allbackTuple
(new CallbackTuple(key, CallbackOb.parseCallback(components.getCallback
(key), context, map
)));
}
if (components.getExtensions() != null) {
for (String key : components.getExtensions().keySet())
componentsObject.addEx
tension
(new Extension(key, components.getExtensions().get(key)));
}
if (components.getSchemas() != null) {
for (String key : components.getSchemas().keySet())
componentsObject.addS(new SchemaTuple(key, SchemaOb.parseSchema(components.getSchema
s().get(key)
)));
}
if (components.getResponses() != null) {
for (String key : components.getResponses().keySet())
componentsObject.addR(new ResponseTuple(key, ResponseOb.parseResponse(components.getResponse
s().get(key)
)));
}
if (components.getParameters() != null) {
for (String key : components.getParameters().keySet())
componentsObject.addP(new ParameterTuple(key, ParameterOb.parseParameter(components.getParameter
s().get(key)
)));
}
if (components.getExamples() != null) {
for (String key : components.getExamples().keySet())
componentsObject.addE(new ExampleTuple(key, ExampleObject.parseExample(components.getExample
s().get(key)
)));
}
if (components.getRequestBodies() != null) {
for (String key : components.getRequestBodies().keySet())
componentsObject.addR
b
(new RequestBodyTuple(key, RequestBodyOb.parseRequestBody(components.getRequestBod
ies().get(key)
)));
}
if (components.getHeaders() != null) {
for (String key : components.getHeaders().keySet())
componentsObject.addH(new HeaderTuple(key, HeaderOb.parseHeader(components.getHeader
s().get(key)
)));
}
if (components.getSecuritySchemes() != null) {
for (String key : components.getSecuritySchemes().keySet())
componentsObject.addS
c
(new SecuritySchemeTuple(key, SecuritySchemeOb.parseSecurityScheme(components.getSecurityScheme
s().get(key)
)));
}
if (components.getLinks() != null) {
for (String key : components.getLinks().keySet())
componentsObject.addL(new LinkTuple(key, LinkOb.parseLink(components.getLink
s().get(key)
)));
}
if (components.getCallbacks() != null) {
for (String key : components.getCallbacks().keySet())
componentsObject.addC(new CallbackTuple(key, CallbackOb.parseCallback(components.getCallback
s().get(key)
)));
}
if (components.getExtensions() != null) {
for (String key : components.getExtensions().keySet())
componentsObject.addEx(new Extension(key, components.getExtensions().get(key)));
}
map.put(components, componentsObject);
return componentsObject;
return componentsObject;
}
public static PathItemObject PathItemObject.parsePath(Path path, OAIContext context, Map<Object, ASTNode> map) throws DecodeException {
Loading