Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an OpenAPIComparator #194

Merged
merged 16 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-22.04
env:
STTP_NATIVE: 1
JAVA_OPTS: -Xmx4G -Xss4M # larger stack needed due to Circe generating large trees: https://github.com/lampepfl/dotty/issues/18669
JAVA_OPTS: -Xmx6G -Xss4M # larger stack needed due to Circe generating large trees: https://github.com/lampepfl/dotty/issues/18669
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
23 changes: 22 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ lazy val allProjectAggregates: Seq[ProjectReference] =
openapiCirceYaml.projectRefs ++
asyncapiModel.projectRefs ++
asyncapiCirce.projectRefs ++
asyncapiCirceYaml.projectRefs
asyncapiCirceYaml.projectRefs ++
openapiComparatorTests.projectRefs

lazy val projectAggregates: Seq[ProjectReference] = if (sys.env.isDefinedAt("STTP_NATIVE")) {
println("[info] STTP_NATIVE defined, including native in the aggregate projects")
Expand Down Expand Up @@ -262,3 +263,23 @@ lazy val asyncapiCirceYaml: ProjectMatrix = (projectMatrix in file("asyncapi-cir
settings = commonJvmSettings
)
.dependsOn(asyncapiCirce)

lazy val openapiComparatorTests: ProjectMatrix = (projectMatrix in file("openapi-comparator-tests"))
abdelfetah18 marked this conversation as resolved.
Show resolved Hide resolved
.settings(commonSettings)
.settings(
name := "openapi-comparator-tests",
publish / skip := true
)
.jvmPlatform(
scalaVersions = scalaJVMVersions,
settings = commonJvmSettings
)
.jsPlatform(
scalaVersions = scalaJSVersions,
settings = commonJsSettings
)
.nativePlatform(
scalaVersions = scalaNativeVersions,
settings = commonNativeSettings
)
.dependsOn(openapiModel, openapiCirce, circeTestUtils % Test)
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"openapi": "3.0.3",
"info": {
"title": "Simple Pet Store API",
"version": "1.0.0"
},
"paths": {
"/pets": {
"post": {
"summary": "Add a new pet",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
}
}
}
},
"responses": {
"201": {
"description": "Pet created successfully."
}
},
"callbacks": {
"onPetStatusChange": {
"{$request.body#/callbackUrl}": {
"post": {
"summary": "Notify about pet status change",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string"
},
"timestamp": {
"type": "string",
"format": "date-time"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Callback successfully processed."
}
}
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"openapi": "3.0.3",
"info": {
"title": "Simple Pet Store API",
"version": "1.0.0"
},
"paths": {
"/pets": {
"post": {
"summary": "Add a new pet",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
}
}
}
},
"responses": {
"201": {
"description": "Pet created successfully."
}
},
"callbacks": {}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"openapi": "3.1.0",
"info": {
"title": "Sample Pet Store App",
"summary": "A pet store manager.",
"description": "This is a sample server for a pet store.",
"termsOfService": "https://example.com/terms/",
"contact": {
"name": "API Support",
"url": "https://www.example.com/support",
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "1.0.3"
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/pets": {
"get": {
"operationId": "getPets",
"description": "Gets all pets",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
}
}
},
"post": {
"operationId": "addPet",
"description": "Add a new pet",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NewPet"
}
}
}
},
"responses": {
"201": {
"description": "Pet created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
}
}
},
"/pets/{petId}": {
"get": {
"operationId": "getPetById",
"description": "Get a pet by its ID",
"parameters": [
{
"name": "petId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
},
"description": "The ID of the pet to retrieve"
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"404": {
"description": "Pet not found"
}
}
}
}
},
"components": {
"schemas": {
"Pet": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"name": {
"type": "string"
}
}
},
"NewPet": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"openapi": "3.1.0",
"info": {
"title": "Sample Pet Store App",
"summary": "A pet store manager.",
"description": "This is a sample server for a pet store.",
"termsOfService": "https://example.com/terms/",
"contact": {
"name": "API Support",
"url": "https://www.example.com/support",
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "1.0.2"
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/pets": {
"get": {
"operationId": "getPets",
"description": "Gets all pets",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
}
}
}
},
"/pets/{petId}": {
"get": {
"operationId": "getPetById",
"description": "Get a pet by its ID",
"parameters": [
{
"name": "petId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
},
"description": "The ID of the pet to retrieve"
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"404": {
"description": "Pet not found"
}
}
}
}
},
"components": {
"schemas": {
"Pet": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"name": {
"type": "string"
}
}
}
}
}
}
Loading
Loading