Skip to content

HydraCollectionBaseSchema example type fails Redocly openapi linter #7767

@GregoireHebert

Description

@GregoireHebert

Hydra example type should be prefixed with a @

See Redocly linter failing test

❯ make openapi.lint

    ╔═══════════════════════════════════════════════════════╗
    ║                                                       ║
    ║  A new version of Redocly CLI (2.18.0) is available.  ║
    ║  Update now: `npm i -g @redocly/cli@latest`.          ║
    ║  Changelog: https://redocly.com/docs/cli/changelog/   ║
    ║                                                       ║
    ╚═══════════════════════════════════════════════════════╝

validating openapi.yaml...
[1] openapi.yaml:6250:17 at #/components/schemas/HydraCollectionBaseSchema/allOf/1/properties/hydra:view/example/type                                                                                                                                                                                                                                                                   

Example value must conform to the schema: must NOT have unevaluated properties `type`.

6248 | example:
6249 |   '@id': string
6250 |   type: string
6251 |   'hydra:first': string
6252 |   'hydra:last': string

referenced from openapi.yaml:6229:15 at #/components/schemas/HydraCollectionBaseSchema/allOf/1/properties/hydra:view 

Error was generated by the no-invalid-schema-examples rule.


openapi.yaml: validated in 215ms
                                                                                                                                                                                                                                                                                                                                                                                        
❌ Validation failed with 1 error.                                             

See proposed patch

Index: vendor/api-platform/hydra/JsonSchema/SchemaFactory.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/api-platform/hydra/JsonSchema/SchemaFactory.php b/vendor/api-platform/hydra/JsonSchema/SchemaFactory.php
--- a/vendor/api-platform/hydra/JsonSchema/SchemaFactory.php
+++ b/vendor/api-platform/hydra/JsonSchema/SchemaFactory.php	(date 1771249437456)
@@ -229,7 +229,7 @@
                                 ],
                                 'example' => [
                                     '@id' => 'string',
-                                    'type' => 'string',
+                                    '@type' => 'string',
                                     $hydraPrefix.'first' => 'string',
                                     $hydraPrefix.'last' => 'string',
                                     $hydraPrefix.'previous' => 'string',

'type' => 'string',

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions