Skip to content
Snippets Groups Projects
Commit ae9bb233 authored by Johannes Mey's avatar Johannes Mey
Browse files

Merge branch 'tests/openapi-generator' into 'main'

Tests/openapi generator

Closes #1

See merge request !1
parents fcec0f14 e74806b6
No related branches found
No related tags found
1 merge request!1Tests/openapi generator
Pipeline #13026 passed
Showing
with 2343 additions and 2014 deletions
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- build
- test
- ragdoc
- publish
build:
image: openjdk:11
stage: build
script:
- "./gradlew relast"
- "./gradlew assemble"
artifacts:
paths:
- "src/gen/java"
- "src/gen/jastadd"
test:
image: openjdk:11
stage: test
needs:
- build
script:
- "./gradlew test"
artifacts:
reports:
junit: "*/build/test-results/test/TEST-*.xml"
paths:
- "src/gen/resources"
ragdoc_build:
image:
name: "git-st.inf.tu-dresden.de:4567/jastadd/ragdoc-builder"
entrypoint: [""]
stage: ragdoc
needs:
- build
script:
- JAVA_FILES="$(find src/main -name '*.java') $(find src/gen -name '*.java')"
- /ragdoc-builder/start-builder.sh -excludeGenerated -d data/ $JAVA_FILES
artifacts:
paths:
- "data/"
ragdoc_view:
image:
name: "git-st.inf.tu-dresden.de:4567/jastadd/ragdoc-view:relations"
entrypoint: [""]
stage: ragdoc
needs:
- ragdoc_build
script:
- DATA_DIR=$(pwd -P)/data
- mkdir -p pages/docs/ragdoc
- OUTPUT_DIR=$(pwd -P)/pages/docs/ragdoc
- cd /ragdoc-view/src/ && rm -rf data && ln -s $DATA_DIR
- /ragdoc-view/build-view.sh --output-path=$OUTPUT_DIR
only:
- tests/openapi-generator
- main
artifacts:
paths:
- "pages/docs/ragdoc"
pages:
image: python:3.10.0-bullseye
stage: publish
needs:
- ragdoc_view
- test
before_script:
- pip install -r pages/requirements.txt
script:
- cd pages && mkdocs build
artifacts:
paths:
- public/
only:
- tests/openapi-generator
- main
...@@ -13,28 +13,50 @@ sourceCompatibility = 1.8 ...@@ -13,28 +13,50 @@ sourceCompatibility = 1.8
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
maven {
name 'gitlab-maven'
url 'https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven'
}
} }
dependencies { dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.1' implementation group: 'com.flipkart.zjsonpatch', name: 'zjsonpatch', version: "${json_patch_version}"
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.12.1' implementation group: 'io.swagger.parser.v3', name: 'swagger-parser', version: "${swagger_parser_version}"
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.12.1'
implementation group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "${junit_jupiter_version}"
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.8' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: "${junit_jupiter_version}"
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.9.8' testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: "${json_path_version}"
implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4' }
implementation group: 'com.flipkart.zjsonpatch', name: 'zjsonpatch', version: '0.4.11'
implementation group: 'org.openapi4j', name: 'openapi-parser', version: '1.0.7' def versionFile = 'src/main/resources/version.properties'
def oldProps = new Properties()
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.7.0' try {
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.7.0' file(versionFile).withInputStream { stream -> oldProps.load(stream) }
testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.6.0' version = oldProps['version']
} catch (e) {
// this happens, if either the properties file is not present, or cannot be read from
throw new GradleException("File ${versionFile} not found or unreadable. Aborting.", e)
}
task printVersion() {
doLast {
println(version)
}
}
task newVersion() {
doFirst {
def props = new Properties()
props['version'] = value
props.store(file(versionFile).newWriter(), null)
}
} }
buildscript { buildscript {
repositories.mavenCentral() repositories.mavenCentral()
dependencies { dependencies {
classpath 'org.jastadd:jastaddgradle:1.13.3' classpath "org.jastadd:jastaddgradle:${jastaddgradle_version}"
} }
} }
...@@ -43,7 +65,7 @@ jar { ...@@ -43,7 +65,7 @@ jar {
manifest { manifest {
attributes( attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '), 'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'de.tudresden.inf.st.openapi' 'Main-Class': "${mainClassName}"
) )
} }
} }
...@@ -54,6 +76,38 @@ test { ...@@ -54,6 +76,38 @@ test {
maxHeapSize = '1G' maxHeapSize = '1G'
} }
// Input and output files for relast
def relastInputFiles = [
"src/main/jastadd/OpenAPISpecification.relast"
]
def relastOutputFiles = [
"src/gen/jastadd/OpenAPISpecification.ast",
"src/gen/jastadd/OpenAPISpecification.jadd"
]
task relast(type: JavaExec) {
classpath = files("libs/relast.jar")
group = 'Build'
doFirst {
delete relastOutputFiles
mkdir "src/gen/jastadd/"
}
args = [
"--listClass=java.util.ArrayList",
"--jastAddList=JastAddList",
"--useJastAddNames",
"--file",
"--resolverHelper",
"--grammarName=./src/gen/jastadd/RelAst"
] + relastInputFiles
inputs.files relastInputFiles
outputs.files relastOutputFiles
}
File genSrc = file("src/gen/java") File genSrc = file("src/gen/java")
sourceSets.main.java.srcDir genSrc sourceSets.main.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc idea.module.generatedSourceDirs += genSrc
...@@ -72,20 +126,11 @@ jastadd { ...@@ -72,20 +126,11 @@ jastadd {
} }
jastadd { jastadd {
basedir "src/main/jastadd/" basedir "src/"
include "**/*.ast" include "**/**/*.ast"
include "**/*.jadd" include "**/**/*.jadd"
include "**/*.jrag" include "**/**/*.jrag"
} }
scanner {
//include "src/main/jastadd/OpenAPISpecification.flex"
}
parser {
//include "src/main/jastadd/OpenAPISpecification.parser"
}
} }
} }
...@@ -95,10 +140,6 @@ jastadd { ...@@ -95,10 +140,6 @@ jastadd {
genDir = 'src/gen/java' genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res' buildInfoDir = 'src/gen-res'
parser.name = 'OpenAPIParser'
scanner.genDir = "src/gen/java/de/tudresden/inf/st/most/jastadd/scanner"
parser.genDir = "src/gen/java/de/tudresden/inf/st/most/jastadd/parser"
jastaddOptions = [ jastaddOptions = [
"--lineColumnNumbers", "--lineColumnNumbers",
......
json_patch_version = 0.4.11
swagger_parser_version = 2.0.30
junit_jupiter_version = 5.7.0
json_path_version = 2.6.0
jastaddgradle_version = 1.13.3
\ No newline at end of file
gradlew 100644 → 100755
File mode changed from 100644 to 100755
File added
{% block footer %}
<p>{% if config.copyright %}
<small>{{ config.copyright }}<br></small>
{% endif %}
<hr>
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
{% if page and page.meta and page.meta.git_revision_date_localized %}
<small><br><i>Last updated {{ page.meta.git_revision_date_localized }}</i></small>
{% endif %}
</p>
{% endblock %}
fuzzing
\ No newline at end of file
Index
\ No newline at end of file
site_name: RAGO - RAG OpenAPI Framework
repo_url: https://git-st.inf.tu-dresden.de/jastadd/rago
site_dir: ../public
nav:
- "Overview": index.md
- "Fuzzing Example": fuzzing.md
- "API documentation": ragdoc/index.html
theme:
name: readthedocs
custom_dir: custom_theme/
markdown_extensions:
- toc:
permalink:
- admonition
- footnotes
plugins:
- search
- git-revision-date-localized:
type: datetime
timezone: Europe/Berlin
locale: en
fallback_to_build_date: True
- macros
mkdocs==1.2.2
mkdocs-git-revision-date-localized-plugin==0.10.3
mkdocs-macros-plugin==0.6.3
This diff is collapsed.
import com.fasterxml.jackson.databind.JsonNode; /*import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
...@@ -199,3 +199,5 @@ aspect InferParameter{ ...@@ -199,3 +199,5 @@ aspect InferParameter{
} }
} }
} }
*/
\ No newline at end of file
//OpenAPI Object
OpenAPIObject ::= <OpenAPI> [InfoObject] ServerObject* PathsObject* [ComponentsObject] SecurityRequirementObject* TagObject* [ExternalDocObject] <Context:OAIContext> Extension* InferredParameter*;
InferredParameter ::= <Parameter>;
//Info Object
InfoObject ::= <Title> <Description> <TermsOfService> [ContactObject] [LicenseObject] <Version> Extension*;
//Contact Object
ContactObject ::= <Name> <Url> <Email> Extension*;
//License Object
LicenseObject ::= <Name> <Url> Extension*;
//Server Object
ServerObject ::= <Url> <Description> ServerVariablesTuple* Extension*;
ServerVariablesTuple ::= <Name> ServerVariableObject;
//Server Variable Object
ServerVariableObject ::= Enum* <Default> <Description> Extension*;
Enum ::= <EnumValue>;
//Components Object
ComponentsObject ::= SchemaTuple* ResponseTuple* ParameterTuple* ExampleTuple* RequestBodyTuple* HeaderTuple* SecuritySchemeTuple* LinkTuple* CallbackTuple* Extension*;
SchemaTuple ::= <Key> SchemaOb;
ResponseTuple ::= <Key> ResponseOb;
ParameterTuple ::= <Key> ParameterOb;
ExampleTuple ::= <Key> ExampleObject;
RequestBodyTuple ::= <Key> RequestBodyOb;
HeaderTuple ::= <Key> HeaderOb;
SecuritySchemeTuple ::= <Key> SecuritySchemeOb;
LinkTuple ::= <Key> LinkOb;
CallbackTuple ::= <Key> CallbackOb;
//Paths Object
PathsObject ::= <Ref> PathItemObject;
//Path Item Object
PathItemObject ::= <Summary> <Description> [Get] [Put] [Post] [Delete] [Options] [Head] [Patch] [Trace] ServerObject* ParameterOb* Extension*;
//Operation Object
OperationObject ::= Tag* <Summary> <Description> [ExternalDocObject] <OperationID> ParameterOb* [RequestBodyOb] ResponseTuple* CallbackTuple* <DeprecatedBoolean:Boolean> SecurityRequirementObject* ServerObject* <Required:Boolean> Extension*;
Get ::= OperationObject;
Put ::= OperationObject;
Post ::= OperationObject;
Delete ::= OperationObject;
Options ::= OperationObject;
Head ::= OperationObject;
Patch ::= OperationObject;
Trace ::= OperationObject;
Tag ::= <Tag:String>;
//External Documentation Object
ExternalDocObject ::= <Description> <Url> Extension*;
//Parameter Object
abstract ParameterOb;
ParameterReference : ParameterOb ::= <Ref>;
ParameterObject : ParameterOb ::= <Name> <In> <Description> <Required:Boolean> <DeprecatedBoolean:Boolean> <AllowEmptyValue:Boolean> <Style> <Explode:Boolean> <AllowReserved:Boolean> [SchemaOb] <Example:Object> ExampleTuple* ContentTuple* Extension*;
ContentTuple ::= <Key> MediaTypeObject;
//Request Body Object
abstract RequestBodyOb;
RequestBodyReference : RequestBodyOb ::= <Ref>;
RequestBodyObject : RequestBodyOb ::= <Description> ContentTuple* <Required:Boolean> Extension*;
//Media Type Object
MediaTypeObject ::= [SchemaOb] <Example:Object> ExampleTuple* EncodingTuple* Extension*;
EncodingTuple ::= <Key> EncodingObject;
//Encoding Object
EncodingObject ::= <ContentType> HeaderTuple* <Style> <Explode:Boolean> <AllowReserved:Boolean> Extension*;
//Response Object
abstract ResponseOb;
ResponseReference : ResponseOb ::= <Ref>;
ResponseObject : ResponseOb ::= <Description> HeaderTuple* ContentTuple* LinkTuple* Extension*;
//Callback Object
abstract CallbackOb;
CallbackReference : CallbackOb ::= <Ref>;
CallbackObject : CallbackOb ::= Expression* Extension*;
Expression ::= <Name> PathItemObject;
Extension ::= <Key> <Value:Object>;
//Example Object
ExampleObject ::= <Summary> <Description> <Value:Object> <ExternalValue> Extension*;
//Link Object
abstract LinkOb;
LinkReference : LinkOb ::= <Ref>;
LinkObject : LinkOb ::= <OperationRef> <OperationID> LinkParameterTuple* HeaderTuple* <Description> [ServerObject] Extension*;
LinkParameterTuple ::= <LinkParameterKey> <LinkParameterValue>;
//Header Object
abstract HeaderOb;
HeaderReference : HeaderOb ::= <Ref>;
HeaderObject : HeaderOb ::= <Description> <Required:Boolean> <DeprecatedBoolean:Boolean> <AllowEmptyValue:Boolean> <Style> <Explode:Boolean> <AllowReserved:Boolean> [SchemaOb] <Example:Object> ExampleTuple* ContentTuple* Extension*;
//Tag Object
TagObject ::= <Name> <Description> [ExternalDocObject] Extension*;
//Schema Object
abstract SchemaOb;
SchemaReference : SchemaOb ::= <Ref>;
SchemaObject : SchemaOb ::= [AdditionalProperties] <AdditionalPropertiesAllowed:Boolean> <DefaultValue:Object> <Description> <DeprecatedBoolean:Boolean> [DiscriminatorObject] EnumObj* <Example:Object> <ExclusiveMaximum:Boolean> <ExclusiveMinimum:Boolean> [ExternalDocObject] <Format> [ItemsSchema] <Maximum:Number> <Minimum:Number> <MaxItems:Integer> <MinItems:Integer> <MaxLength:Integer> <MinLength:Integer> <MaxProperties:Integer> <MinProperties:Integer> <MultipleOf:Number> [NotSchema] <Nullable:Boolean> <Pattern> PropertyItem* RequiredField* AllOfSchema* AnyOfSchema* OneOfSchema* <ReadOnly:Boolean> <WriteOnly:Boolean> <Type> <Title> <UniqueItems:Boolean> [XmlObject] Extension*;
AdditionalProperties ::= SchemaOb;
EnumObj ::= <EnumOb:Object>;
ItemsSchema ::= SchemaOb;
NotSchema ::= SchemaOb;
PropertyItem ::= <Name> SchemaOb;
RequiredField ::= <Value>;
AllOfSchema ::= SchemaOb;
AnyOfSchema ::= SchemaOb;
OneOfSchema ::= SchemaOb;
//Discriminator Object
DiscriminatorObject ::= <PropertyName> MappingTuple*;
MappingTuple ::= <Key> <Value>;
//XML Object
XmlObject ::= <Name> <Namespace> <Prefix> <Attribute:Boolean> <Wrapped:Boolean> Extension*;
//Security Scheme Object
abstract SecuritySchemeOb;
SecuritySchemeReference : SecuritySchemeOb ::= <Ref>;
SecuritySchemeObject : SecuritySchemeOb ::= <Type> <Description> <Name> <In> <Scheme> <BearerFormat> [OAuthFlowsObject] <OpenIdConnectUrl> Extension*;
//OAuth Flows Object
OAuthFlowsObject ::= [Implicit] [Password] [ClientCredentials] [AuthorizationCode] Extension*;
Implicit ::= OAuthFlowObject;
Password ::= OAuthFlowObject;
ClientCredentials ::= OAuthFlowObject;
AuthorizationCode ::= OAuthFlowObject;
//OAuth Flow Object
OAuthFlowObject ::= <AuthorizationUrl> <TokenUrl> <RefreshUrl> ScopesTuple* <Configuration> Extension*;
ScopesTuple ::= <ScopesKey> <ScopesValue>;
//Security Requirement Object
SecurityRequirementObject ::= SecurityRequirementTuple*;
SecurityRequirementTuple ::= <Name> SecurityRequirementValue*;
SecurityRequirementValue ::= <Value>;
\ No newline at end of file
//OpenAPI Object
OpenAPIObject ::= <OpenAPI> <JsonSchemaDialect> I:InfoObject Serv:ServerObject* P:PathsObject* W:Webhook* C:ComponentsObject Sr:SecurityRequirementObject* T:TagObject* [E:ExternalDocObject] Ex:Extension* ;
Webhook ::= <Key> p:PathItemOb;
//Info Object
InfoObject ::= <Title> <Summary> <Description> <TermsOfService> <Version> [C:ContactObject] [L:LicenseObject] Ex:Extension*;
//Contact Object
ContactObject ::= <Name> <Url> <Email> Ex:Extension*;
//License Object
LicenseObject ::= <Name> <Identifier> <Url> Ex:Extension*;
//Server Object
ServerObject ::= <Url> <Description> St:ServerVariablesTuple* Ex:Extension*;
ServerVariablesTuple ::= <Name> S:ServerVariableObject;
//Server Variable Object
ServerVariableObject ::= <Default> <Description> E:Enum* Ex:Extension*;
Enum ::= <EnumValue>;
//Components Object
ComponentsObject ::= S:SchemaTuple* R:ResponseTuple* P:ParameterTuple* E:ExampleTuple* Rb:RequestBodyTuple* H:HeaderTuple* Sc:SecuritySchemeTuple* L:LinkTuple* C:CallbackTuple* Pi:PathItemTuple* Ex:Extension*;
SchemaTuple ::= <Key> O:SchemaOb;
ResponseTuple ::= <Key> O:ResponseOb;
ParameterTuple ::= <Key> O:ParameterOb;
ExampleTuple ::= <Key> O:ExampleOb;
RequestBodyTuple ::= <Key> O:RequestBodyOb;
HeaderTuple ::= <Key> O:HeaderOb;
SecuritySchemeTuple ::= <Key> O:SecuritySchemeOb;
LinkTuple ::= <Key> O:LinkOb;
CallbackTuple ::= <Key> O:CallbackOb;
PathItemTuple ::= <Key> O:PathItemOb;
//Paths Object
PathsObject ::= <Ref> P:PathItemOb Ex:Extension*;
//Path Item Object
abstract PathItemOb;
PathItemReference : PathItemOb ::= <Ref> <Summary> <Description>;
rel PathItemReference.r -> PathItemObject;
PathItemObject : PathItemOb ::= <Ref> <Summary> <Description> [G:Get] [PutOb:Put] [PostOb:Post] [D:Delete] [O:Options] [H:Head] [PatchOb:Patch] [T:Trace] S:ServerObject* Po:ParameterOb* Ex:Extension*;
//Operation Object
OperationObject ::= <Summary> <Description> <OperationID> <DeprecatedBoolean:Boolean> T:Tag* [Ed:ExternalDocObject] P:ParameterOb* [Rb:RequestBodyOb] R:ResponsesObject C:CallbackTuple* Sr:SecurityRequirementObject* S:ServerObject* Ex:Extension*;
Get ::= O:OperationObject;
Put ::= O:OperationObject;
Post ::= O:OperationObject;
Delete ::= O:OperationObject;
Options ::= O:OperationObject;
Head ::= O:OperationObject;
Patch ::= O:OperationObject;
Trace ::= O:OperationObject;
Tag ::= <Tag>;
//External Documentation Object
ExternalDocObject ::= <Description> <Url> Ex:Extension*;
//Parameter Object
abstract ParameterOb;
ParameterReference : ParameterOb ::= <Ref> <Summary> <Description>;
rel ParameterReference.p -> ParameterObject;
ParameterObject : ParameterOb ::= <Name> <In> <Description> <Required:Boolean> <DeprecatedBoolean:Boolean> <AllowEmptyValue:Boolean> <Style> <Explode:Boolean> <AllowReserved:Boolean> <Example:Object> [Schema:SchemaOb] E:ExampleTuple* C:ContentTuple* Ex:Extension*;
ContentTuple ::= <Key> M:MediaTypeObject;
//Request Body Object
abstract RequestBodyOb;
RequestBodyReference : RequestBodyOb ::= <Ref> <Summary> <Description>;
rel RequestBodyReference.r -> RequestBodyObject;
RequestBodyObject : RequestBodyOb ::= <Description> <Required:Boolean> C:ContentTuple* Ex:Extension*;
//Media Type Object
MediaTypeObject ::= <Example:Object> [S:SchemaOb] E:ExampleTuple* En:EncodingTuple* Ex:Extension*;
EncodingTuple ::= <Key> E:EncodingObject;
//Encoding Object
EncodingObject ::= <ContentType> <Style> <Explode:Boolean> <AllowReserved:Boolean> H:HeaderTuple* Ex:Extension*;
//Responses Object (ResponseTuple is used for HTTPStatusCode)
ResponsesObject ::= R:ResponseTuple*;
//Response Object
abstract ResponseOb;
ResponseReference : ResponseOb ::= <Ref> <Summary> <Description>;
rel ResponseReference.r -> ResponseObject;
ResponseObject : ResponseOb ::= <Description> H:HeaderTuple* C:ContentTuple* L:LinkTuple* Ex:Extension*;
//Callback Object
abstract CallbackOb;
CallbackReference : CallbackOb ::= <Ref> <Summary> <Description>;
rel CallbackReference.r -> CallbackObject;
CallbackObject : CallbackOb ::= E:Expression* Ex:Extension*;
Extension ::= <Key> <Value:Object>;
Expression ::= <Name> P:PathItemOb;
//Example Object
abstract ExampleOb;
ExampleReference : ExampleOb ::= <Ref> <Summary> <Description>;
rel ExampleReference.r -> ExampleObject;
ExampleObject : ExampleOb ::= <Summary> <Description> <Value:Object> <ExternalValue> Ex:Extension*;
//Link Object
abstract LinkOb;
LinkReference : LinkOb ::= <Ref> <Summary> <Description>;
rel LinkReference.r -> LinkObject;
LinkObject : LinkOb ::= <OperationRef> <OperationID> <LinkRequestBody:Object> <Description> L:LinkParameterTuple* [S:ServerObject] Ex:Extension*;
LinkParameterTuple ::= <Key> <Value>;
//Header Object
abstract HeaderOb;
HeaderReference : HeaderOb ::= <Ref> <Summary> <Description>;
rel HeaderReference.r -> HeaderObject;
HeaderObject : HeaderOb ::= <Description> <Required:Boolean> <DeprecatedBoolean:Boolean> <AllowEmptyValue:Boolean> <Style> <Explode:Boolean> <AllowReserved:Boolean> <Example:Object> [S:SchemaOb] E:ExampleTuple* C:ContentTuple* Ex:Extension*;
//Tag Object
TagObject ::= <Name> <Description> [E:ExternalDocObject] Ex:Extension*;
//Schema Object ()
abstract SchemaOb;
SchemaReference : SchemaOb ::= <Ref> <Summary> <Description>;
rel SchemaReference.r -> SchemaObject;
SchemaObject : SchemaOb ::= <Name> <AdditionalProperties:Object> <DefaultValue:Object> <Description> <DeprecatedBoolean:Boolean> <ExclusiveMaximum:Boolean> <ExclusiveMinimum:Boolean> <Format> <Maximum:BigDecimal> <Minimum:BigDecimal> <MaxItems:Integer> <MinItems:Integer> <MaxLength:Integer> <MinLength:Integer> <MaxProperties:Integer> <MinProperties:Integer> <MultipleOf:BigDecimal> <Pattern> <ReadOnly:Boolean> <WriteOnly:Boolean> <Type> <Title> <UniqueItems:Boolean> <Nullable:Boolean> <MaxContains:Integer> <MinContains:Integer> <DependentRequired:Object> <DependentSchema:SchemaOb> <Const:Object> [D:DiscriminatorObject] E:EnumObj* El:ExampleElement* [Ext:ExternalDocObject] [I:ItemsSchema] [N:NotSchema] P:PropertyItem* R:RequiredField* All:AllOfSchema* Any:AnyOfSchema* One:OneOfSchema* T:TypeArray* [X:XmlObject] Ex:Extension*;
ItemsSchema ::= Schema:SchemaOb;
NotSchema ::= Schema:SchemaOb;
PropertyItem ::= <Name> Schema:SchemaOb;
AllOfSchema ::= Schema:SchemaOb;
AnyOfSchema ::= Schema:SchemaOb;
OneOfSchema ::= Schema:SchemaOb;
ExampleElement ::= <Example:Object>;
TypeArray ::= <TypeElements:Object>;
EnumObj ::= <EnumOb:Object>;
RequiredField ::= <Value>;
//Discriminator Object
DiscriminatorObject ::= <PropertyName> M:MappingTuple* Ex:Extension*;
MappingTuple ::= <Key> <Value>;
//XML Object
XmlObject ::= <Name> <Namespace> <Prefix> <Attribute:Boolean> <Wrapped:Boolean> Ex:Extension*;
//Security Scheme Object
abstract SecuritySchemeOb;
SecuritySchemeReference : SecuritySchemeOb ::= <Ref> <Summary> <Description>;
rel SecuritySchemeReference.r -> SecuritySchemeObject;
SecuritySchemeObject : SecuritySchemeOb ::= <Type> <Description> <Name> <In> <Scheme> <BearerFormat> <OpenIdConnectUrl> [O:OAuthFlowsObject] Ex:Extension*;
//OAuth Flows Object
OAuthFlowsObject ::= [I:Implicit] [P:Password] [C:ClientCredentials] [A:AuthorizationCode] Ex:Extension*;
Implicit ::= O:OAuthFlowObject;
Password ::= O:OAuthFlowObject;
ClientCredentials ::= O:OAuthFlowObject;
AuthorizationCode ::= O:OAuthFlowObject;
//OAuth Flow Object
OAuthFlowObject ::= <AuthorizationUrl> <TokenUrl> <RefreshUrl> S:ScopesTuple* Ex:Extension*;
ScopesTuple ::= <ScopesKey> <ScopesValue>;
//Security Requirement Object
SecurityRequirementObject ::= Tuple:SecurityRequirementTuple*;
SecurityRequirementTuple ::= <Name> Value:SecurityRequirementValue*;
SecurityRequirementValue ::= <Value>;
\ No newline at end of file
This diff is collapsed.
/*
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
...@@ -192,3 +193,5 @@ aspect RandomRequestGenerator{ ...@@ -192,3 +193,5 @@ aspect RandomRequestGenerator{
return String.valueOf(rand.nextInt()); return String.valueOf(rand.nextInt());
} }
} }
*/
\ No newline at end of file
/*
import java.util.*;
aspect Reference { aspect Reference {
inh OpenAPIObject ASTNode.root();
eq OpenAPIObject.getChild().root() = this;
coll List<SchemaTuple> OpenAPIObject.schemaTuples() [new ArrayList<>()] root OpenAPIObject;
SchemaTuple contributes this
to OpenAPIObject.schemaTuples();
coll List<ResponseTuple> OpenAPIObject.responseTuples() [new ArrayList<>()] root OpenAPIObject;
ResponseTuple contributes this
to OpenAPIObject.responseTuples();
coll List<ParameterTuple> OpenAPIObject.parameterTuples() [new ArrayList<>()] root OpenAPIObject;
ParameterTuple contributes this
to OpenAPIObject.parameterTuples();
coll List<RequestBodyTuple> OpenAPIObject.requestBodyTuples() [new ArrayList<>()] root OpenAPIObject;
RequestBodyTuple contributes this
to OpenAPIObject.requestBodyTuples();
coll List<HeaderTuple> OpenAPIObject.headerTuples() [new ArrayList<>()] root OpenAPIObject;
HeaderTuple contributes this
to OpenAPIObject.headerTuples();
coll List<SecuritySchemeTuple> OpenAPIObject.securitySchemeTuples() [new ArrayList<>()] root OpenAPIObject;
SecuritySchemeTuple contributes this
to OpenAPIObject.securitySchemeTuples();
coll List<LinkTuple> OpenAPIObject.linkTuples() [new ArrayList<>()] root OpenAPIObject;
LinkTuple contributes this
to OpenAPIObject.linkTuples();
coll List<CallbackTuple> OpenAPIObject.callbackTuples() [new ArrayList<>()] root OpenAPIObject;
CallbackTuple contributes this
to OpenAPIObject.callbackTuples();
syn ParameterObject ParameterOb.parameterObject(); syn ParameterObject ParameterOb.parameterObject();
eq ParameterObject.parameterObject() = this; eq ParameterObject.parameterObject() = this;
eq ParameterReference.parameterObject() { eq ParameterReference.parameterObject() {
...@@ -81,3 +118,4 @@ aspect Reference { ...@@ -81,3 +118,4 @@ aspect Reference {
} }
} }
*/
\ No newline at end of file
This diff is collapsed.
package de.tudresden.inf.st.openapi; package de.tudresden.inf.st.openapi;
import de.tudresden.inf.st.openapi.ast.OpenAPIObject; import com.fasterxml.jackson.databind.JsonNode;
import org.openapi4j.core.validation.ValidationResults; import com.fasterxml.jackson.databind.ObjectMapper;
import org.openapi4j.parser.OpenApi3Parser; import io.swagger.models.reader.SwaggerParser;
import org.openapi4j.parser.model.v3.OpenApi3; import io.swagger.parser.OpenAPIParser;
import io.swagger.report.MessageBuilder;
import java.io.File; import io.swagger.util.Yaml;
import java.io.FileNotFoundException; import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.OpenAPIV3Parser;
import io.swagger.v3.parser.core.models.ParseOptions;
import io.swagger.v3.parser.core.models.SwaggerParseResult;
import io.swagger.v3.parser.util.OpenAPIDeserializer;
import io.swagger.validate.ApiDeclarationJsonValidator;
import io.swagger.validate.SwaggerSchemaValidator;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class OpenAPIMain { public class OpenAPIMain {
...@@ -19,37 +31,43 @@ public class OpenAPIMain { ...@@ -19,37 +31,43 @@ public class OpenAPIMain {
* main-method, calls the set of methods to test the OpenAPI-Generator with JastAdd * main-method, calls the set of methods to test the OpenAPI-Generator with JastAdd
**/ **/
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
OpenAPIObject openApi = new OpenAPIObject();
OpenApi3 api3;
ValidationResults results;
List<String> filenames = new ArrayList<>(); List<String> filenames = new ArrayList<>();
String genDir = "./gen-api-ex/"; String genDir = "./gen-api-ex/";
File genDirectory = new File(genDir); File genDirectory = new File(genDir);
File[] contents; File[] contents;
File resource = new File("./src/main/resources"); File resource = new File("./src/main/resources");
for (File file : resource.listFiles()) // init parser
filenames.add(file.getName()); String fileName = "./src/main/resources/3.0/petstore.yaml";
System.out.println(filenames.size());
/* /*
for( String file : filenames ){ ParseOptions options = new ParseOptions();
String writerName = genDir + file; options.setResolve(true);
options.setResolveFully(true);
options.setAllowEmptyString(false);
*/
SwaggerParseResult result = new OpenAPIParser().readLocation(fileName, null, null);
URL expUrl = OpenAPIMain.class.getClassLoader().getResource(file); String resultString;
OpenApi3 api = new OpenApi3Parser().parse(expUrl, new ArrayList<>(), true); OpenAPI openAPI = result.getOpenAPI();
System.out.println("Loading expression DSL file '" + file + "'.");
openApi = OpenAPIObject.parseOpenAPI(api); OpenAPIDeserializer deserializer = new OpenAPIDeserializer();
api3 = OpenAPIObject.composeOpenAPI(openApi); String res = Json.mapper().writeValueAsString(openAPI);
openApi.generateRequests(); ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(res);
//System.out.println(node.toPrettyString());
}
*/
String fileName = "petstore-v2.yaml"; /** OpenAPI Validator! **/
//FileWriter writer = new FileWriter("./gen-api-ex/callback-example_generated.json"); List<String> validation = new OpenAPIV3Parser().readContents(res).getMessages();
for(String mes : validation)
System.out.println("message : " + mes);
//Json.mapper().createParser(Json.mapper().writeValueAsString(openAPI)).
// Yaml String
//System.out.println(Yaml.mapper().writerWithDefaultPrettyPrinter().writeValueAsString(openAPI));
//resultString = Yaml.mapper().writerWithDefaultPrettyPrinter().writeValueAsString(openAPI);
URL expUrl = OpenAPIMain.class.getClassLoader().getResource(fileName); URL expUrl = OpenAPIMain.class.getClassLoader().getResource(fileName);
File file = null; File file = null;
...@@ -62,18 +80,8 @@ public class OpenAPIMain { ...@@ -62,18 +80,8 @@ public class OpenAPIMain {
throw new FileNotFoundException("Could not load JSON file " + fileName); throw new FileNotFoundException("Could not load JSON file " + fileName);
} }
OpenApi3 api = new OpenApi3Parser().parse(expUrl, new ArrayList<>(), true);
System.out.println("Loading expression DSL file '" + fileName + "'."); System.out.println("Loading expression DSL file '" + fileName + "'.");
openApi = OpenAPIObject.parseOpenAPI(api);
openApi.generateRequestsWithInferredParameters();
//writer.write(api3.toNode().toPrettyString());
//writer.close();
Map<String, List<String>> s = new HashMap<>();
if (args.length > 0) { if (args.length > 0) {
fileName = args[0]; fileName = args[0];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment