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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
RAGO - RAG OpenAPI Framework
Commits
c2222fd6
Commit
c2222fd6
authored
Feb 26, 2022
by
Jueun Park
Browse files
Options
Downloads
Patches
Plain Diff
edit Parser.jrag fully
parent
2038b0b2
No related branches found
No related tags found
1 merge request
!1
Tests/openapi generator
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/jastadd/OpenAPISpecification.relast
+1
-4
1 addition, 4 deletions
src/main/jastadd/OpenAPISpecification.relast
src/main/jastadd/Parser.jrag
+461
-432
461 additions, 432 deletions
src/main/jastadd/Parser.jrag
with
462 additions
and
436 deletions
src/main/jastadd/OpenAPISpecification.relast
+
1
−
4
View file @
c2222fd6
...
...
@@ -251,10 +251,7 @@ rel TagObject.ex* -> Extension;
//Schema Object
abstract SchemaOb;
SchemaReference : SchemaOb ::= <Ref> <Summary> <Description>;
SchemaObject : SchemaOb ::= <AdditionalPropertiesAllowed:Boolean> <DefaultValue:Object> <Description> <DeprecatedBoolean:Boolean> <ExclusiveMaximum:Number> <ExclusiveMinimum:Number> <Format> <Maximum:Number> <Minimum:Number> <MaxItems:Integer> <MinItems:Integer> <MaxLength:Integer> <MinLength:Integer> <MaxProperties:Integer> <MinProperties:Integer> <MultipleOf:Number> <Pattern> <ReadOnly:Boolean> <WriteOnly:Boolean> <Type> <Title> <UniqueItems:Boolean> <MaxContains:Integer> <MinContains:Integer> <DependentRequired:Object> <DependentSchema:SchemaOb> <Const:Object>;
AdditionalProperties;
rel AdditionalProperties.s -> SchemaOb;
SchemaObject : SchemaOb ::= <AdditionalProperties:Object> <DefaultValue:Object> <Description> <DeprecatedBoolean:Boolean> <ExclusiveMaximum:Number> <ExclusiveMinimum:Number> <Format> <Maximum:Number> <Minimum:Number> <MaxItems:Integer> <MinItems:Integer> <MaxLength:Integer> <MinLength:Integer> <MaxProperties:Integer> <MinProperties:Integer> <MultipleOf:Number> <Pattern> <ReadOnly:Boolean> <WriteOnly:Boolean> <Type> <Title> <UniqueItems:Boolean> <MaxContains:Integer> <MinContains:Integer> <DependentRequired:Object> <DependentSchema:SchemaOb> <Const:Object>;
ItemsSchema;
rel ItemsSchema.s -> SchemaOb;
...
...
This diff is collapsed.
Click to expand it.
src/main/jastadd/Parser.jrag
+
461
−
432
View file @
c2222fd6
import io.swagger.models.*;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.callbacks.*;
...
...
@@ -42,7 +43,7 @@ aspect Parser {
}
if (api.getExternalDocs() != null)
openapi.set_impl_e(ExternalDocObject.parseExternalDocs(api.getExternalDocs()));
if (api.getExtensions()
!= null
) {
if (api.getExtensions()
.size() != 0
) {
for (String key : api.getExtensions().keySet())
openapi.addEx(new Extension(key, api.getExtensions().get(key)));
}
...
...
@@ -69,7 +70,7 @@ aspect Parser {
infoObject.set_impl_c(ContactObject.parseContact(info.getContact()));
if (info.getLicense() != null)
infoObject.set_impl_l(LicenseObject.parseLicense(info.getLicense()));
if (info.getExtensions()
!= null
) {
if (info.getExtensions()
.size() != 0
) {
for (String key : info.getExtensions().keySet())
infoObject.addEx(new Extension(key, info.getExtensions().get(key)));
}
...
...
@@ -90,7 +91,7 @@ aspect Parser {
contactObject.setUrl(contact.getUrl());
if (contact.getEmail() != null)
contactObject.setEmail(contact.getEmail());
if (contact.getExtensions()
!= null
) {
if (contact.getExtensions()
.size() != 0
) {
for (String key : contact.getExtensions().keySet())
contactObject.addEx(new Extension(key, contact.getExtensions().get(key)));
}
...
...
@@ -105,7 +106,7 @@ aspect Parser {
licenseObject.setName(license.getName());
if (license.getUrl() != null)
licenseObject.setUrl(license.getUrl());
if (license.getExtensions()
!= null
) {
if (license.getExtensions()
.size() != 0
) {
for (String key : license.getExtensions().keySet())
licenseObject.addEx(new Extension(key, license.getExtensions().get(key)));
}
...
...
@@ -128,7 +129,7 @@ aspect Parser {
for (String key : server.getVariables().keySet())
serverObject.addSt(new ServerVariablesTuple(key, ServerVariableObject.parseServerVariable(server.getVariables().get(key))));
}
if (server.getExtensions()
!= null
) {
if (server.getExtensions()
.size() != 0
) {
for (String key : server.getExtensions().keySet())
serverObject.addEx(new Extension(key, server.getExtensions().get(key)));
}
...
...
@@ -147,7 +148,7 @@ aspect Parser {
for (String e : serverVariable.getEnum())
serverVariableObject.addE(new Enum(e));
}
if (serverVariable.getExtensions()
!= null
) {
if (serverVariable.getExtensions()
.size() != 0
) {
for (String key : serverVariable.getExtensions().keySet())
serverVariableObject.addEx(new Extension(key, serverVariable.getExtensions().get(key)));
}
...
...
@@ -194,7 +195,7 @@ aspect Parser {
for (String key : components.getCallbacks().keySet())
componentsObject.addC(new CallbackTuple(key, CallbackOb.parseCallback(components.getCallbacks().get(key))));
}
if (components.getExtensions()
!= null
) {
if (components.getExtensions()
.size() != 0
) {
for (String key : components.getExtensions().keySet())
componentsObject.addEx(new Extension(key, components.getExtensions().get(key)));
}
...
...
@@ -274,7 +275,7 @@ aspect Parser {
for (Parameter p : path.getParameters())
pathItem.addPo(ParameterOb.parseParameter(p));
}
if (path.getExtensions()
!= null
) {
if (path.getExtensions()
.size() != 0
) {
for (String key : path.getExtensions().keySet())
pathItem.addEx(new Extension(key, path.getExtensions().get(key)));
}
...
...
@@ -326,7 +327,7 @@ aspect Parser {
for (Server s : operation.getServers())
operationObject.addS(ServerObject.parseServer(s));
}
if (operation.getExtensions()
!= null
) {
if (operation.getExtensions()
.size() != 0
) {
for (String key : operation.getExtensions().keySet())
operationObject.addEx(new Extension(key, operation.getExtensions().get(key)));
}
...
...
@@ -349,12 +350,19 @@ aspect Parser {
return externalDocObject;
}
public static ParameterOb ParameterOb.parseParameter(Parameter parameter
, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
public static ParameterOb ParameterOb.parseParameter(Parameter parameter
)
{
ParameterObject parameterObject = new ParameterObject();
if (parameter.
isRef()
) {
if (parameter.
get$ref() != null
) {
ParameterReference p = new ParameterReference();
p.setRef(parameter.getRef());
p.setRef(parameter.get$ref());
/* 3.1.0 features
if (parameter.getSummary() != null) ...
if (parameter.getDescription() != null) ...
if (parameter.getParameter() != null) ...
*/
return p;
} else {
if (parameter.getName() != null)
...
...
@@ -366,162 +374,176 @@ aspect Parser {
if (parameter.getDeprecated() != null)
parameterObject.setDeprecatedBoolean(parameter.getDeprecated());
if (parameter.getStyle() != null)
parameterObject.setStyle(parameter.getStyle());
parameterObject.setStyle(parameter.getStyle()
.toString()
);
if (parameter.getExplode() != null)
parameterObject.setExplode(parameter.getExplode());
if (parameter.getAllowReserved() != null)
parameterObject.setAllowReserved(parameter.getAllowReserved());
if (parameter.getSchema() != null)
parameterObject.set
SchemaOb
(SchemaOb.parseSchema(parameter.getSchema()
, context, map
));
parameterObject.set
_impl_s
(SchemaOb.parseSchema(parameter.getSchema()));
if (parameter.getExample() != null)
parameterObject.setExample(parameter.getExample());
if (parameter.getExamples() != null) {
for (String key : parameter.getExamples().keySet())
parameterObject.addE
xampleTuple
(new ExampleTuple(key, ExampleObject.parseExample(parameter.getExample
(key), context, map
)));
parameterObject.addE(new ExampleTuple(key, ExampleObject.parseExample(parameter.getExample
s().get(key)
)));
}
if (parameter.getContent
MediaTypes
() != null) {
for (String key : parameter.getContent
MediaTypes
().keySet())
parameterObject.addC
ontentTuple
(new ContentTuple(key, MediaTypeObject.parseMediaType(parameter.getContent
MediaType(key), context, map
)));
if (parameter.getContent() != null) {
for (String key : parameter.getContent().keySet())
parameterObject.addC(new ContentTuple(key, MediaTypeObject.parseMediaType(parameter.getContent
().get(key)
)));
}
if (parameter.getRequired() != null)
parameterObject.setRequired(parameter.getRequired());
if (parameter.getExtensions()
!= null
) {
if (parameter.getExtensions()
.size() != 0
) {
for (String key : parameter.getExtensions().keySet())
parameterObject.addEx
tension
(new Extension(key, parameter.getExtensions().get(key)));
parameterObject.addEx(new Extension(key, parameter.getExtensions().get(key)));
}
}
map.put(parameter, parameterObject);
return parameterObject;
}
public static RequestBodyOb RequestBodyOb.parseRequestBody(
org.openapi4j.parser.model.v3.RequestBody requestBody, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
public static RequestBodyOb RequestBodyOb.parseRequestBody(
RequestBody requestBody)
{
RequestBodyObject requestBodyObject = new RequestBodyObject();
if (requestBody.
isRef()
) {
if (requestBody.
get$ref() != null
) {
RequestBodyReference r = new RequestBodyReference();
r.setRef(requestBody.getRef());
r.setRef(requestBody.get$ref());
/* 3.1.0 features
if (requestBody.getSummary() != null) ...
if (requestBody.getDescription() != null) ...
*/
return r;
} else {
if (requestBody.getContent
MediaTypes
() != null) {
for (String key : requestBody.getContent
MediaTypes
().keySet())
requestBodyObject.addC
ontentTuple
(new ContentTuple(key, MediaTypeObject.parseMediaType(requestBody.getContent
MediaType(key), context, map
)));
if (requestBody.getContent() != null) {
for (String key : requestBody.getContent().keySet())
requestBodyObject.addC(new ContentTuple(key, MediaTypeObject.parseMediaType(requestBody.getContent
().get(key)
)));
}
if (requestBody.getDescription() != null)
requestBodyObject.setDescription(requestBody.getDescription());
if (requestBody.getRequired() != null)
requestBodyObject.setRequired(requestBody.getRequired());
if (requestBody.getExtensions()
!= null
) {
if (requestBody.getExtensions()
.size() != 0
) {
for (String key : requestBody.getExtensions().keySet())
requestBodyObject.addEx
tension
(new Extension(key, requestBody.getExtensions().get(key)));
requestBodyObject.addEx(new Extension(key, requestBody.getExtensions().get(key)));
}
}
map.put(requestBody, requestBodyObject);
return requestBodyObject;
}
public static MediaTypeObject MediaTypeObject.parseMediaType(MediaType mediaType
, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
public static MediaTypeObject MediaTypeObject.parseMediaType(MediaType mediaType
)
{
MediaTypeObject mediaTypeObject = new MediaTypeObject();
if (mediaType.getSchema() != null)
mediaTypeObject.set
SchemaOb
(SchemaObject.parseSchema(mediaType.getSchema()
, context, map
));
mediaTypeObject.set
_impl_s
(SchemaObject.parseSchema(mediaType.getSchema()));
if (mediaType.getExample() != null)
mediaTypeObject.setExample(mediaType.getExample());
if (mediaType.getExamples()
!= null
) {
if (mediaType.getExamples()
.size() != 0
) {
for (String key : mediaType.getExamples().keySet())
mediaTypeObject.addE
xampleTuple
(new ExampleTuple(key, ExampleObject.parseExample(mediaType.getExample
(key), context, map
)));
mediaTypeObject.addE(new ExampleTuple(key, ExampleObject.parseExample(mediaType.getExample
s().get(key)
)));
}
if (mediaType.getEncoding
s
() !=
null
) {
for (String key : mediaType.getEncoding
s
().keySet())
mediaTypeObject.addEn
codingTuple
(new EncodingTuple(key, EncodingObject.parseEncoding(mediaType.getEncoding(
key), context, map
)));
if (mediaType.getEncoding
().size
() !=
0
) {
for (String key : mediaType.getEncoding().keySet())
mediaTypeObject.addEn(new EncodingTuple(key, EncodingObject.parseEncoding(mediaType.getEncoding(
).get(key)
)));
}
if (mediaType.getExtensions()
!= null
) {
if (mediaType.getExtensions()
.size() != 0
) {
for (String key : mediaType.getExtensions().keySet())
mediaTypeObject.addEx
tension
(new Extension(key, mediaType.getExtensions().get(key)));
mediaTypeObject.addEx(new Extension(key, mediaType.getExtensions().get(key)));
}
map.put(mediaType, mediaTypeObject);
return mediaTypeObject;
}
public static EncodingObject EncodingObject.parseEncoding(EncodingProperty encodingProperty
, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
public static EncodingObject EncodingObject.parseEncoding(EncodingProperty encodingProperty
)
{
EncodingObject encodingObject = new EncodingObject();
if (encodingProperty.getContentType() != null)
encodingObject.setContentType(encodingProperty.getContentType());
if (encodingProperty.getHeaders() != null) {
for (String key : encodingProperty.getHeaders().keySet())
encodingObject.addH
eaderTuple
(new HeaderTuple(key, HeaderObject.parseHeader(encodingProperty.getHeader
(key), context, map
)));
encodingObject.addH(new HeaderTuple(key, HeaderObject.parseHeader(encodingProperty.getHeader
s().get(key)
)));
}
if (encodingProperty.getStyle() != null)
encodingObject.setStyle(encodingProperty.getStyle());
encodingObject.setStyle(encodingProperty.getStyle()
.toString()
);
if (encodingProperty.getExplode() != null)
encodingObject.setExplode(encodingProperty.getExplode());
if (encodingProperty.getAllowReserved() != null)
encodingObject.setAllowReserved(encodingProperty.getAllowReserved());
if (encodingProperty.getExtensions() != null) {
for (String key : encodingProperty.getExtensions().keySet())
encodingObject.addEx
tension
(new Extension(key, encodingProperty.getExtensions().get(key)));
encodingObject.addEx(new Extension(key, encodingProperty.getExtensions().get(key)));
}
map.put(encodingProperty, encodingObject);
return encodingObject;
}
public static ResponseOb ResponseOb.parseResponse(Response response
, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
public static ResponseOb ResponseOb.parseResponse(
Api
Response response
)
{
ResponseObject responseObject = new ResponseObject();
if (response.
isRef()
) {
if (response.
get$ref() != null
) {
ResponseReference r = new ResponseReference();
r.setRef(response.getRef());
r.setRef(response.get$ref());
/* 3.1.0 features
if (response.getSummary() != null) ...
if (response.getDescription() != null) ...
*/
return r;
} else {
if (response.getDescription() != null)
responseObject.setDescription(response.getDescription());
if (response.getHeaders()
!= null
) {
if (response.getHeaders()
.size() != 0
) {
for (String key : response.getHeaders().keySet())
responseObject.addH
eaderTuple
(new HeaderTuple(key, HeaderObject.parseHeader(response.getHeader
(key), context, map
)));
responseObject.addH(new HeaderTuple(key, HeaderObject.parseHeader(response.getHeader
s().get(key)
)));
}
if (response.getContent
MediaTypes
() !=
null
) {
for (String key : response.getContent
MediaTypes
().keySet())
responseObject.addC
ontentTuple
(new ContentTuple(key, MediaTypeObject.parseMediaType(response.getContent
MediaType(key), context, map
)));
if (response.getContent
().size
() !=
0
) {
for (String key : response.getContent().keySet())
responseObject.addC(new ContentTuple(key, MediaTypeObject.parseMediaType(response.getContent
().get(key))
)));
}
if (response.getLinks()
!= null
) {
if (response.getLinks()
.size() != 0
) {
for (String key : response.getLinks().keySet())
responseObject.addL
inkTuple
(new LinkTuple(key, LinkOb.parseLink(response.getLink
(key), context, map
)));
responseObject.addL(new LinkTuple(key, LinkOb.parseLink(response.getLink
s().get(key)
)));
}
if (response.getExtensions()
!= null
) {
if (response.getExtensions()
.size() != 0
) {
for (String key : response.getExtensions().keySet())
responseObject.addEx
tension
(new Extension(key, response.getExtensions().get(key)));
responseObject.addEx(new Extension(key, response.getExtensions().get(key)));
}
}
map.put(response, responseObject);
return responseObject;
}
public static CallbackOb CallbackOb.parseCallback(Callback callback
, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
public static CallbackOb CallbackOb.parseCallback(Callback callback
)
{
CallbackObject callbackObject = new CallbackObject();
if (callback.
isRef()
) {
if (callback.
get$ref() != null
) {
CallbackReference c = new CallbackReference();
c.setRef(callback.getRef());
c.setRef(callback.get$ref());
/* 3.1.0 features
if (callback.getSummary() != null) ...
if (callback.getDescription() != null) ...
*/
return c;
} else {
if (callback.
getCallbackPaths
() !=
null
) {
for (String key : callback.
getCallbackPaths().
keySet())
callbackObject.addE
xpression
(new Expression(key, PathItemObject.parsePath(callback.get
CallbackPath(key), context, map
)));
if (callback.
size
() !=
0
) {
for (String key : callback.keySet())
callbackObject.addE(new Expression(key, PathItemObject.parsePath(callback.get
(key)
)));
}
if (callback.getExtensions()
!= null
) {
if (callback.getExtensions()
.size() != 0
) {
for (String key : callback.getExtensions().keySet())
callbackObject.addEx
tension
(new Extension(key, callback.getExtensions().get(key)));
callbackObject.addEx(new Extension(key, callback.getExtensions().get(key)));
}
}
map.put(callback, callbackObject);
return callbackObject;
}
public static ExampleObject ExampleObject.parseExample(Example example
, OAIContext context, Map<Object, ASTNode> map
){
public static ExampleObject ExampleObject.parseExample(Example example){
ExampleObject exampleObject = new ExampleObject();
if (example.getSummary() != null)
...
...
@@ -532,56 +554,61 @@ aspect Parser {
exampleObject.setValue(example.getValue());
if (example.getExternalValue() != null)
exampleObject.setExternalValue(example.getExternalValue());
if (example.getExtensions() != null) {
for (String key : example.getExtensions().keySet())
exampleObject.addExtension(new Extension(key, example.getExtensions().get(key)));
}
if (example.getExtensions() != null) {
if (example.getExtensions().size() != 0) {
for (String key : example.getExtensions().keySet())
exampleObject.addEx
tension
(new Extension(key, example.getExtensions().get(key)));
exampleObject.addEx(new Extension(key, example.getExtensions().get(key)));
}
map.put(example, exampleObject);
return exampleObject;
}
public static LinkOb LinkOb.parseLink(Link link
, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
public static LinkOb LinkOb.parseLink(Link link
)
{
LinkObject linkObject = new LinkObject();
if (link.
isRef()
) {
if (link.
get$ref() != null
) {
LinkReference l = new LinkReference();
l.setRef(link.getRef());
l.setRef(link.get$ref());
/* 3.1.0 features
if (link.getSummary() != null) ...
if (link.getDescription() != null) ...
*/
return l;
} else {
if (link.getOperationRef() != null)
linkObject.setOperationRef(link.getOperationRef());
if (link.getOperationId() != null)
linkObject.setOperationID(link.getOperationId());
if (link.getParameters()
!= null
) {
if (link.getParameters()
.size() != 0
) {
for (String key : link.getParameters().keySet())
linkObject.addL
inkParameterTuple
(new LinkParameterTuple(key, link.getParameter(key)));
linkObject.addL(new LinkParameterTuple(key, link.getParameter
s().get
(key)));
}
if (link.getDescription() != null)
linkObject.setDescription(link.getDescription());
if (link.getServer() != null)
linkObject.set
ServerObject
(ServerObject.parseServer(link.getServer()
, map
));
if (link.getExtensions()
!= null
) {
linkObject.set
_impl_s
(ServerObject.parseServer(link.getServer()));
if (link.getExtensions()
.size() != 0
) {
for (String key : link.getExtensions().keySet())
linkObject.addEx
tension
(new Extension(key, link.getExtensions().get(key)));
linkObject.addEx(new Extension(key, link.getExtensions().get(key)));
}
}
map.put(link, linkObject);
return linkObject;
}
public static HeaderOb HeaderOb.parseHeader(Header header
, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
public static HeaderOb HeaderOb.parseHeader(Header header
)
{
HeaderObject headerObject = new HeaderObject();
if (header.
isRef()
) {
if (header.
get$ref() != null
) {
HeaderReference h = new HeaderReference();
h.setRef(header.getRef());
h.setRef(header.get$ref());
/* 3.1.0 features
if (header.getSummary() != null) ...
if (header.getDescription() != null) ...
*/
return h;
} else {
if (header.getRequired() != null)
...
...
@@ -591,34 +618,31 @@ aspect Parser {
if (header.getDeprecated() != null)
headerObject.setDeprecatedBoolean(header.getDeprecated());
if (header.getStyle() != null)
headerObject.setStyle(header.getStyle());
headerObject.setStyle(header.getStyle()
.toString()
);
if (header.getExplode() != null)
headerObject.setExplode(header.getExplode());
if (header.getAllowReserved() != null)
headerObject.setExplode(header.getAllowReserved());
if (header.getExample() != null)
headerObject.setExample(header.getExample());
if (header.getExamples()
!= null
) {
if (header.getExamples()
.size() != 0
) {
for (String key : header.getExamples().keySet())
headerObject.addE
xampleTuple
(new ExampleTuple(key, ExampleObject.parseExample(header.getExample
(key), context, map
)));
headerObject.addE(new ExampleTuple(key, ExampleObject.parseExample(header.getExample
s().get(key)
)));
}
if (header.getContent
MediaTypes
() !=
null
) {
for (String key : header.getContent
MediaTypes
().keySet())
headerObject.addC
ontentTuple
(new ContentTuple(key, MediaTypeObject.parseMediaType(header.getContent
MediaType(key), context, map
)));
if (header.getContent
().size
() !=
0
) {
for (String key : header.getContent().keySet())
headerObject.addC(new ContentTuple(key, MediaTypeObject.parseMediaType(header.getContent
().get(key))
)));
}
if (header.getSchema() != null)
headerObject.set
SchemaOb
(SchemaOb.parseSchema(header.getSchema()
, context, map
));
headerObject.set
_impl_s
(SchemaOb.parseSchema(header.getSchema()));
if (header.getExtensions() != null) {
for (String key : header.getExtensions().keySet())
headerObject.addEx
tension
(new Extension(key, header.getExtensions().get(key)));
headerObject.addEx(new Extension(key, header.getExtensions().get(key)));
}
}
map.put(header, headerObject);
return headerObject;
}
public static TagObject TagObject.parseTag(
org.openapi4j.parser.model.v3.Tag tag, Map<Object, ASTNode> map
){
public static TagObject TagObject.parseTag(
Tag tag
){
TagObject tagObject = new TagObject();
tagObject.setName(tag.getName());
...
...
@@ -626,32 +650,31 @@ aspect Parser {
if (tag.getDescription() != null)
tagObject.setDescription(tag.getDescription());
if (tag.getExternalDocs() != null)
tagObject.set
ExternalDocObject
(ExternalDocObject.parseExternalDocs(tag.getExternalDocs()
, map
));
if (tag.getExtensions()
!= null
) {
tagObject.set
_impl_e
(ExternalDocObject.parseExternalDocs(tag.getExternalDocs()));
if (tag.getExtensions()
.size() != 0
) {
for (String key : tag.getExtensions().keySet())
tagObject.addExtension(new Extension(key, tag.getExtensions().get(key)));
}
if (tag.getExtensions() != null) {
for (String key : tag.getExtensions().keySet())
tagObject.addExtension(new Extension(key, tag.getExtensions().get(key)));
tagObject.addEx(new Extension(key, tag.getExtensions().get(key)));
}
map.put(tag, tagObject);
return tagObject;
}
public static SchemaOb SchemaOb.parseSchema (
org.openapi4j.parser.model.v3.
Schema schema
, OAIContext context, Map<Object, ASTNode> map) throws DecodeException
{
public static SchemaOb SchemaOb.parseSchema (Schema
<?>
schema
)
{
SchemaObject schemaObject = new SchemaObject();
if (schema.
isRef()
) {
if (schema.
get$ref() != null
) {
SchemaReference s = new SchemaReference();
s.setRef(schema.getRef());
s.setRef(schema.get$ref());
/* 3.1.0 features
if (schema.getSummary() != null) ...
if (schema.getDescription() != null) ...
*/
return s;
} else {
if (schema.getAdditionalProperties() != null)
schemaObject.setAdditionalProperties(new AdditionalProperties(parseSchema(schema.getAdditionalProperties(), context, map)));
if (schema.getAdditionalProperties() == null && schema.getAdditionalPropertiesAllowed() != null)
schemaObject.setAdditionalPropertiesAllowed(schema.getAdditionalPropertiesAllowed());
schemaObject.setAdditionalProperties(schema.getAdditionalProperties());
if (schema.getDefault() != null)
schemaObject.setDefaultValue(schema.getDefault());
if (schema.getDescription() != null)
...
...
@@ -659,30 +682,27 @@ aspect Parser {
if (schema.getDeprecated() != null)
schemaObject.setDeprecatedBoolean(schema.getDeprecated());
if (schema.getDiscriminator() != null)
schemaObject.setD
iscriminatorObject
(DiscriminatorObject.parseDiscriminator(schema.getDiscriminator()
, map
));
if (schema.getEnum
s
() != null) {
for (Object o : schema.getEnum
s
()) {
schemaObject.setD(DiscriminatorObject.parseDiscriminator(schema.getDiscriminator()));
if (schema.getEnum() != null) {
for (Object o : schema.getEnum()) {
EnumObj enumObj = new EnumObj();
enumObj.setEnumOb(o);
schemaObject.addE
numObj
(enumObj);
schemaObject.addE(enumObj);
}
}
// in 3.1.0, there are multiple examples
if (schema.getExample() != null)
schemaObject.setExample(schema.getExample());
schemaObject.addEl(new ExampleElement(schema.getExample()));
/* in 3.1.0, types are Number instead of Boolean
if (schema.getExclusiveMaximum() != null)
schemaObject.setExclusiveMaximum(schema.getExclusiveMaximum());
if (schema.getExclusiveMinimum() != null)
schemaObject.setExclusiveMinimum(schema.getExclusiveMinimum());
*/
if (schema.getExternalDocs() != null)
schemaObject.setExt
ernalDocObject
(ExternalDocObject.parseExternalDocs(schema.getExternalDocs()
, map
));
schemaObject.setExt(ExternalDocObject.parseExternalDocs(schema.getExternalDocs()));
if (schema.getFormat() != null)
schemaObject.setFormat(schema.getFormat());
if (schema.getItemsSchema() != null) {
ItemsSchema itemsSchema = new ItemsSchema();
itemsSchema.setSchemaOb(parseSchema(schema.getItemsSchema(), context, map));
schemaObject.setItemsSchema(itemsSchema);
}
if (schema.getMaximum() != null)
schemaObject.setMaximum(schema.getMaximum());
if (schema.getMinimum() != null)
...
...
@@ -701,29 +721,32 @@ aspect Parser {
schemaObject.setMinProperties(schema.getMinProperties());
if (schema.getMultipleOf() != null)
schemaObject.setMultipleOf(schema.getMultipleOf());
if (schema.getNot
Schema
() != null) {
if (schema.getNot() != null) {
NotSchema notSchema = new NotSchema();
notSchema.set
SchemaOb
(parseSchema(schema.getNot
Schema(), context, map
));
schemaObject.set
NotSchema
(notSchema);
notSchema.set
_impl_s
(parseSchema(schema.getNot
()
));
schemaObject.set
_impl_n
(notSchema);
}
if (schema.getNullable() != null)
schemaObject.setNullable(schema.getNullable());
if (schema.getPattern() != null)
schemaObject.setPattern(schema.getPattern());
if (schema.getProperties()
!= null
) {
if (schema.getProperties()
.size() != 0
) {
for (String key : schema.getProperties().keySet()) {
PropertyItem propertyItem = new PropertyItem();
schemaObject.addP
ropertyItem
(new PropertyItem(key, parseSchema(schema.getPropert
y(key), context, map
)));
schemaObject.addP(new PropertyItem(key, parseSchema(schema.getPropert
ies().get(key)
)));
}
}
if (schema.getRequired
Fields
() !=
null
) {
for (String s : schema.getRequired
Fields
()) {
if (schema.getRequired
().size
() !=
0
) {
for (String s : schema.getRequired()) {
RequiredField requiredField = new RequiredField();
requiredField.setValue(s);
schemaObject.addR
equiredField
(requiredField);
schemaObject.addR(requiredField);
}
}
/* Schemas not supported (maybe supported in 3.1.0)
if (schema.getItemsSchema() != null) {
ItemsSchema itemsSchema = new ItemsSchema();
itemsSchema.setSchemaOb(parseSchema(schema.getItemsSchema(), context, map));
schemaObject.setItemsSchema(itemsSchema);
}
if (schema.getAllOfSchemas() != null) {
for (org.openapi4j.parser.model.v3.Schema schemaItem : schema.getAllOfSchemas()) {
AllOfSchema allOfSchema = new AllOfSchema();
...
...
@@ -745,6 +768,7 @@ aspect Parser {
schemaObject.addOneOfSchema(oneOfSchema);
}
}
*/
if (schema.getReadOnly() != null)
schemaObject.setReadOnly(schema.getReadOnly());
if (schema.getWriteOnly() != null)
...
...
@@ -756,18 +780,17 @@ aspect Parser {
if (schema.getUniqueItems() != null)
schemaObject.setUniqueItems(schema.getUniqueItems());
if (schema.getXml() != null)
schemaObject.setX
mlObject
(XmlObject.parseXml(schema.getXml()
, map
));
if (schema.getExtensions()
!= null
) {
schemaObject.setX(XmlObject.parseXml(schema.getXml()));
if (schema.getExtensions()
.size() != 0
) {
for (String key : schema.getExtensions().keySet())
schemaObject.addEx
tension
(new Extension(key, schema.getExtensions().get(key)));
schemaObject.addEx(new Extension(key, schema.getExtensions().get(key)));
}
}
map.put(schema, schemaObject);
return schemaObject;
}
public static DiscriminatorObject DiscriminatorObject.parseDiscriminator (Discriminator discriminator
, Map<Object, ASTNode> map
) {
public static DiscriminatorObject DiscriminatorObject.parseDiscriminator (Discriminator discriminator) {
DiscriminatorObject discriminatorObject = new DiscriminatorObject();
if (discriminator.getPropertyName() != null)
...
...
@@ -777,15 +800,14 @@ aspect Parser {
for (String key : discriminator.getMapping().keySet()) {
mapping.setKey(key);
mapping.setValue(discriminator.getMapping().get(key));
discriminatorObject.addM
appingTuple
(mapping);
discriminatorObject.addM(mapping);
}
}
map.put(discriminator, discriminatorObject);
return discriminatorObject;
}
public static XmlObject XmlObject.parseXml (Xml xml
, Map<Object, ASTNode> map
) {
public static XmlObject XmlObject.parseXml (Xml xml) {
XmlObject xmlObject = new XmlObject();
if (xml.getName() != null)
...
...
@@ -798,44 +820,54 @@ aspect Parser {
xmlObject.setAttribute(xml.getAttribute());
if (xml.getWrapped() != null)
xmlObject.setWrapped(xml.getWrapped());
map.put(xml, xmlObject);
if (xml.getExtensions() != null) {
for (String key : xml.getExtensions().keySet())
xmlObject.addEx
tension
(new Extension(key, xml.getExtensions().get(key)));
xmlObject.addEx(new Extension(key, xml.getExtensions().get(key)));
}
return xmlObject;
}
public static SecuritySchemeOb SecuritySchemeOb.parseSecurityScheme(SecurityScheme securityScheme
, OAIContext context, Map<Object, ASTNode> map
){
public static SecuritySchemeOb SecuritySchemeOb.parseSecurityScheme(SecurityScheme securityScheme){
SecuritySchemeObject securitySchemeObject = new SecuritySchemeObject();
if(securityScheme.get$ref() != null){
SecuritySchemeReference r = new SecuritySchemeReference();
r.setRef(securityScheme.get$ref());
/* 3.1.0 features
if (securityScheme.getSummary() != null) ...
if (securityScheme.getDescription() != null) ...
*/
return r;
} else {
if (securityScheme.getType() != null)
securitySchemeObject.setType(securityScheme.getType());
securitySchemeObject.setType(securityScheme.getType()
.toString()
);
if (securityScheme.getName() != null)
securitySchemeObject.setName(securityScheme.getName());
if (securityScheme.getIn() != null)
securitySchemeObject.setIn(securityScheme.getIn());
securitySchemeObject.setIn(securityScheme.getIn()
.toString()
);
if (securityScheme.getScheme() != null)
securitySchemeObject.setScheme(securityScheme.getScheme());
if (securityScheme.getOpenIdConnectUrl() != null)
securitySchemeObject.setOpenIdConnectUrl(securityScheme.getOpenIdConnectUrl());
if (securityScheme.getFlows() != null)
securitySchemeObject.setO
AuthFlowsObject
(OAuthFlowsObject.parseOAuthFlows(securityScheme.getFlows()
, map
));
securitySchemeObject.setO(OAuthFlowsObject.parseOAuthFlows(securityScheme.getFlows()));
if (securityScheme.getDescription() != null)
securitySchemeObject.setDescription(securityScheme.getDescription());
if (securityScheme.getBearerFormat() != null)
securitySchemeObject.setBearerFormat(securityScheme.getBearerFormat());
if (securityScheme.getExtensions() != null) {
for (String key : securityScheme.getExtensions().keySet())
securitySchemeObject.addExtension(new Extension(key, securityScheme.getExtensions().get(key)));
securitySchemeObject.addEx(new Extension(key, securityScheme.getExtensions().get(key)));
}
}
map.put(securityScheme, securitySchemeObject);
return securitySchemeObject;
}
public static OAuthFlowsObject OAuthFlowsObject.parseOAuthFlows(OAuthFlows oAuthFlows
, Map<Object, ASTNode> map
){
public static OAuthFlowsObject OAuthFlowsObject.parseOAuthFlows(OAuthFlows oAuthFlows){
OAuthFlowsObject oAuthFlowsObject = new OAuthFlowsObject();
Implicit implicit = new Implicit();
Password password = new Password();
...
...
@@ -843,31 +875,30 @@ aspect Parser {
AuthorizationCode authorizationCode = new AuthorizationCode();
if (oAuthFlows.getImplicit() != null) {
implicit.set
OAuthFlowObject
(OAuthFlowObject.parseOAuthFlow(oAuthFlows.getImplicit(), map));
oAuthFlowsObject.set
I
mpli
cit
(implicit);
implicit.set
_impl_o
(OAuthFlowObject.parseOAuthFlow(oAuthFlows.getImplicit(), map));
oAuthFlowsObject.set
_i
mpl
_
i(implicit);
}
if (oAuthFlows.getPassword() != null) {
password.set
OAuthFlowObject
(OAuthFlowObject.parseOAuthFlow(oAuthFlows.getPassword(), map));
oAuthFlowsObject.set
Password
(password);
password.set
_impl_o
(OAuthFlowObject.parseOAuthFlow(oAuthFlows.getPassword(), map));
oAuthFlowsObject.set
_impl_p
(password);
}
if (oAuthFlows.getClientCredentials() != null) {
clientCredentials.set
OAuthFlowObject
(OAuthFlowObject.parseOAuthFlow(oAuthFlows.getClientCredentials(), map));
oAuthFlowsObject.set
ClientCredentials
(clientCredentials);
clientCredentials.set
_impl_o
(OAuthFlowObject.parseOAuthFlow(oAuthFlows.getClientCredentials(), map));
oAuthFlowsObject.set
_impl_c
(clientCredentials);
}
if (oAuthFlows.getAuthorizationCode() != null) {
authorizationCode.set
OAuthFlowObject
(OAuthFlowObject.parseOAuthFlow(oAuthFlows.getAuthorizationCode(), map));
oAuthFlowsObject.set
AuthorizationCode
(authorizationCode);
authorizationCode.set
_impl_o
(OAuthFlowObject.parseOAuthFlow(oAuthFlows.getAuthorizationCode(), map));
oAuthFlowsObject.set
_impl_a
(authorizationCode);
}
if (oAuthFlows.getExtensions() != null) {
for (String key : oAuthFlows.getExtensions().keySet())
oAuthFlowsObject.addEx
tension
(new Extension(key, oAuthFlows.getExtensions().get(key)));
oAuthFlowsObject.addEx(new Extension(key, oAuthFlows.getExtensions().get(key)));
}
map.put(oAuthFlows, oAuthFlowsObject);
return oAuthFlowsObject;
}
public static OAuthFlowObject OAuthFlowObject.parseOAuthFlow(OAuthFlow oAuthFlow
, Map<Object, ASTNode> map
){
public static OAuthFlowObject OAuthFlowObject.parseOAuthFlow(OAuthFlow oAuthFlow){
OAuthFlowObject oAuthFlowObject = new OAuthFlowObject();
if (oAuthFlow.getAuthorizationUrl() != null)
...
...
@@ -875,31 +906,29 @@ aspect Parser {
if (oAuthFlow.getTokenUrl() != null)
oAuthFlowObject.setTokenUrl(oAuthFlow.getTokenUrl());
for (String key : oAuthFlow.getScopes().keySet())
oAuthFlowObject.addS
copesTuple
(new ScopesTuple(key, oAuthFlow.getScope(key)));
oAuthFlowObject.addS(new ScopesTuple(key, oAuthFlow.getScope
s().get
(key)));
if (oAuthFlow.getRefreshUrl() != null)
oAuthFlowObject.setRefreshUrl(oAuthFlow.getRefreshUrl());
if (oAuthFlow.getExtensions() != null) {
for (String key : oAuthFlow.getExtensions().keySet())
oAuthFlowObject.addEx
tension
(new Extension(key, oAuthFlow.getExtensions().get(key)));
oAuthFlowObject.addEx(new Extension(key, oAuthFlow.getExtensions().get(key)));
}
map.put(oAuthFlow, oAuthFlowObject);
return oAuthFlowObject;
}
public static SecurityRequirementObject SecurityRequirementObject.parseSecurityRequirement(SecurityRequirement securityRequirement
, Map<Object, ASTNode> map
){
public static SecurityRequirementObject SecurityRequirementObject.parseSecurityRequirement(SecurityRequirement securityRequirement){
SecurityRequirementObject securityRequirementObject = new SecurityRequirementObject();
if (securityRequirement
.getRequirements()
!= null) {
for (String key : securityRequirement.
getRequirements().
keySet()) {
JastAdd
List<SecurityRequirementValue> values = new
JastAdd
List<>();
for (String v : securityRequirement.get
Requirement
(key))
if (securityRequirement != null) {
for (String key : securityRequirement.keySet()) {
List<SecurityRequirementValue> values = new
Array
List<>();
for (String v : securityRequirement.get(key))
values.add(new SecurityRequirementValue(v));
securityRequirementObject.add
SecurityRequirementTuple
(new SecurityRequirementTuple(key, values));
securityRequirementObject.add
T
(new SecurityRequirementTuple(key, values));
}
}
map.put(securityRequirement, securityRequirementObject);
return securityRequirementObject;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment