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

feat(json-schema): mutualize json schema between formats #6960

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all 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
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -425,16 +425,15 @@ jobs:
- name: Export OpenAPI documents
run: |
mkdir -p build/out/openapi
tests/Fixtures/app/console api:openapi:export -o build/out/openapi/openapi_v3.json
# tests/Fixtures/app/console api:openapi:export -o build/out/openapi/openapi_v3.json
tests/Fixtures/app/console api:openapi:export --yaml -o build/out/openapi/openapi_v3.yaml
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '14'
- name: Validate OpenAPI documents
run: |
npx swagger-cli validate build/out/openapi/openapi_v3.json
npx swagger-cli validate build/out/openapi/openapi_v3.yaml
npx @quobix/vacuum lint validate build/out/openapi/openapi_v3.yaml
- name: Upload OpenAPI artifacts
if: always()
uses: actions/upload-artifact@v4
@@ -1227,16 +1226,15 @@ jobs:
- name: Export OpenAPI documents
run: |
mkdir -p build/out/openapi
tests/Fixtures/app/console api:openapi:export -o build/out/openapi/openapi_v3.json
# tests/Fixtures/app/console api:openapi:export -o build/out/openapi/openapi_v3.json
tests/Fixtures/app/console api:openapi:export --yaml -o build/out/openapi/openapi_v3.yaml
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '14'
- name: Validate OpenAPI documents
run: |
npx swagger-cli validate build/out/openapi/openapi_v3.json
npx swagger-cli validate build/out/openapi/openapi_v3.yaml
npx @quobix/vacuum lint validate build/out/openapi/openapi_v3.yaml
- name: Upload OpenAPI artifacts
if: always()
uses: actions/upload-artifact@v4
109 changes: 1 addition & 108 deletions features/openapi/docs.feature
Original file line number Diff line number Diff line change
@@ -153,10 +153,9 @@ Feature: Documentation support
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters" should have 6 elements

# Subcollection - check schema
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.responses.200.content.application/ld+json.schema.properties.hydra:member.items.$ref" should be equal to "#/components/schemas/RelatedToDummyFriend.jsonld-fakemanytomany"
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.responses.200.content.application/ld+json.schema.allOf[1].properties.hydra:member.items.$ref" should be equal to "#/components/schemas/RelatedToDummyFriend.jsonld-fakemanytomany"

# Deprecations
And the JSON node "paths./dummies.get.deprecated" should be false
And the JSON node "paths./deprecated_resources.get.deprecated" should be true
And the JSON node "paths./deprecated_resources.post.deprecated" should be true
And the JSON node "paths./deprecated_resources/{id}.get.deprecated" should be true
@@ -166,111 +165,6 @@ Feature: Documentation support

# Formats
And the OpenAPI class "Dummy.jsonld" exists
And the "@id" property exists for the OpenAPI class "Dummy.jsonld"
And the JSON node "paths./dummies.get.responses.200.content.application/ld+json" should be equal to:
"""
{
"schema": {
"type": "object",
"properties": {
"hydra:member": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Dummy.jsonld"
}
},
"hydra:totalItems": {
"type": "integer",
"minimum": 0
},
"hydra:view": {
"type": "object",
"properties": {
"@id": {
"type": "string",
"format": "iri-reference"
},
"@type": {
"type": "string"
},
"hydra:first": {
"type": "string",
"format": "iri-reference"
},
"hydra:last": {
"type": "string",
"format": "iri-reference"
},
"hydra:previous": {
"type": "string",
"format": "iri-reference"
},
"hydra:next": {
"type": "string",
"format": "iri-reference"
}
},
"example": {
"@id": "string",
"type": "string",
"hydra:first": "string",
"hydra:last": "string",
"hydra:previous": "string",
"hydra:next": "string"
}
},
"hydra:search": {
"type": "object",
"properties": {
"@type": {
"type": "string"
},
"hydra:template": {
"type": "string"
},
"hydra:variableRepresentation": {
"type": "string"
},
"hydra:mapping": {
"type": "array",
"items": {
"type": "object",
"properties": {
"@type": {
"type": "string"
},
"variable": {
"type": "string"
},
"property": {
"type": ["string", "null"]
},
"required": {
"type": "boolean"
}
}
}
}
}
}
},
"required": [
"hydra:member"
]
}
}
"""
And the JSON node "paths./dummies.get.responses.200.content.application/json" should be equal to:
"""
{
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Dummy"
}
}
}
"""
And the JSON node "paths./override_open_api_responses.post.responses" should be equal to:
"""
{
@@ -322,7 +216,6 @@ Feature: Documentation support
And the "resourceRelated" property for the OpenAPI class "Resource" should be equal to:
"""
{
"readOnly": true,
"anyOf": [
{
"$ref": "#/components/schemas/ResourceRelated"
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/DateFilter.php
Original file line number Diff line number Diff line change
@@ -248,7 +248,7 @@ private function addMatch(Builder $aggregationBuilder, string $field, string $op
*/
public function getSchema(Parameter $parameter): array
{
return ['type' => 'date'];
return ['type' => 'string', 'format' => 'date'];
}

public function getOpenApiParameters(Parameter $parameter): OpenApiParameter|array|null
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/NumericFilter.php
Original file line number Diff line number Diff line change
@@ -168,6 +168,6 @@ protected function getType(?string $doctrineType = null): string

public function getSchema(Parameter $parameter): array
{
return ['type' => 'numeric'];
return ['type' => 'number'];
}
}
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/DateFilter.php
Original file line number Diff line number Diff line change
@@ -280,7 +280,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf
*/
public function getSchema(Parameter $parameter): array
{
return ['type' => 'date'];
return ['type' => 'string', 'format' => 'date'];
}

public function getOpenApiParameters(Parameter $parameter): OpenApiParameter|array|null
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/NumericFilter.php
Original file line number Diff line number Diff line change
@@ -181,6 +181,6 @@ protected function getType(?string $doctrineType = null): string

public function getSchema(Parameter $parameter): array
{
return ['type' => 'numeric'];
return ['type' => 'number'];
}
}
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.