Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

json-schema integration not up to the spec #76

@rdohms

Description

@rdohms

Scenario:

#%RAML 0.8
title: Sample for Schema Support
version: 1
baseUri: http://some.example.com
protocols: [ HTTPS, HTTP ]
mediaType: application/hal+json
schemas:
  - account: |
      {
        "type": "object",
        "$schema": "http://json-schema.org/draft-03/schema",
        "id": "http://jsonschema.net",
        "required": true,

        "properties": {
          "id": {
            "type": "string",
            "required": false
          },
          "emails": {
              "type": "array",
              "items": { "$ref": "email" }
          }
        }
      }
  - email: |
      {
        "type": "object",
        "$schema": "http://json-schema.org/draft-03/schema",
        "id": "http://jsonschema.net",
        "required": true,
        "properties": {
          "id": {
            "type": "string",
            "required": false
          },
          "address": {
            "type": "string",
            "required": true
          },
          "primary": {
            "type": "boolean",
            "required": true
          },
          "confirmed": {
            "type": "boolean",
            "required": true
          }
        }
      }

/accounts:
  displayName: Accounts
  description: Handles all account operations
  get:
    description: Find and list accounts
    responses:
      200:
        body:
          application/json:
            schema: account

Using the above example i should get a valid result to navigate (raml successfully parsed), and (as a bonus) my json-schema would load the email entity inside the account emails property.

However it tries to load email as if its a remote json-schema file


Fatal error: Uncaught exception 'JsonSchema\Exception\ResourceNotFoundException' with message 'JSON schema not found at file://./email' in vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php on line 38

JsonSchema\Exception\ResourceNotFoundException: JSON schema not found at file://./email in vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php on line 38

I believe this is an issue in how processing is handed over to json-schema but i'm not entirely sure where the blame lies.

I tried other RAML parsers:

  • js: raml was parsed. json-schema $ref was ignored
{ body: { 'application/json': { schema: '{
  "type": "object",
  "$schema": "http://json-schema.org/draft-03/schema",
  "id": "http://jsonschema.net",
  "required": true,

  "properties": {
    "id": {
      "type": "string",
      "required": false
    },
    "emails": {
        "type": "array",
        "items": { "$ref": "email" }
    }
  }
}
' } } }
  • python-raml: raml was parsed, schema not expanded
{'body': OrderedDict([('application/json', {'notNull': None, 'formParameters': None, 'example': None, 'schema': 'account'})]), 'headers': None, 'description': None, 'notNull': None}

in the schemas property $ref was also not expanded.

Is there an option to avoid the complete crash and just keep going with the superficial data from schema?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions