Skip to content

Commit

Permalink
Merge pull request #194 from abdelfetah18/openapi_comparator
Browse files Browse the repository at this point in the history
Implement an OpenAPIComparator
  • Loading branch information
adamw authored Dec 18, 2024
2 parents ade7f5c + 1c41d74 commit 1bdcaf5
Show file tree
Hide file tree
Showing 89 changed files with 14,520 additions and 2 deletions.
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"))
.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

0 comments on commit 1bdcaf5

Please sign in to comment.