question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The generator does not handle allOf/anyOf/oneOf properly if schemas include properties, and are not references.

See original GitHub issue

This schema:

{
  "$id" : "id",
  "title" : "title",
  "description" : "desc", 
  "type" : "object",

  "allOf": [
    { "properties": {
        "type": { "enum": [ "one", "two" ] }
      }, "required" : ["type"]
    },
    { "properties": {
        "test": { "type": "string" }
      }, "required" : ["test"]
    }
  ]
}

Produces this MarkDown:

# title Schema

id


desc

| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In |
|----------|------------|--------|-------------------|-----------------------|------------|
| Can be instantiated | No | Experimental | Forbidden | Permitted | [protocol2.schema.json](protocol2.schema.json) |

# title Properties

| Property | Type | Required | Defined by |
|----------|------|----------|------------|
| [test](#test) | `string` | **Required** | title (this schema) |
| `*` | any | Additional | this schema *allows* additional properties |

## test


`test`
* is **required**
* type: `string`
* defined in this schema

### test Type


`string`

The “type” property disappears completely. However, this is a valid schema that requires both properties. Additionally, if you change one of the “allOf” elements to “$ref” with the same content, everything works just fine.

The same problem applies to anyOf and oneOf combinations.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
trieloffcommented, Dec 16, 2019

🎉 This issue has been resolved in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

0reactions
AndyOGocommented, May 24, 2018

I face the same issue, using allOf and mixin a ref with properties.

My schema:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$id": "http://www.axa.ch/schemas/components/Link.json",
    "type": "object",
    "title": "Link",
    "description": "Renders a Link.",
    "additionalProperties": false,
    "required": [
        "name",
        "component"
    ],
    "properties": {
        "name": {
            "$ref": "http://www.axa.ch/schemas/types/bpmid.json#"
        },
        "component": {
            "allOf": [
                {
                    "$ref": "http://www.axa.ch/schemas/types/component.json#"
                },
                {
                    "enum": [
                        "Link"
                    ]
                }
            ]
        },
        "properties": {
            "type": "object",
            "title": "Properties",
            "description": "Properties of Link.",
            "additionalProperties": false,
            "properties": {
                "value": {
                    "type": "string",
                    "title": "Value",
                    "description": "The value of the Link."
                },
                "href": {
                    "type": "string",
                    "title": "Href",
                    "description": "URL of the Link."
                }
            }
        },
        "style": {
            "type": "object",
            "title": "Style",
            "description": "Styles of Textarea.",
            "additionalProperties": false,
            "properties": {
                "color": {
                    "type": "string",
                    "title": "Color",
                    "description": "Color of Link.",
                    "enum": [
                        "red",
                        "white",
                        "blue"
                    ],
                    "default": "blue"
                },
                "listed": {
                    "type": "boolean",
                    "title": "Listed",
                    "description": "Whether or not to us lested style.",
                    "default": "false"
                },
                "arrow": {
                    "type": "boolean",
                    "title": "Arrow",
                    "description": "Whether or not to display an arrow icon or not.",
                    "default": "false"
                },
                "motion": {
                    "type": "boolean",
                    "title": "Motion",
                    "description": "Whether or not to use animation upon hovering.",
                    "default": "false"
                }
            }
        },
        "events": {
            "type": "array",
            "title": "Events",
            "description": "Supported events of Link.",
            "uniqueItems": true,
            "additionalItems": false,
            "items": [
                {
                    "$ref": "http://www.axa.ch/schemas/types/event.json#"
                }
            ]
        }
    }
}

And the generated markdown:


# Link Schema

http://www.axa.ch/schemas/components/Link.json


Renders a Link.

| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Defined In |
|----------|------------|--------|--------------|-------------------|-----------------------|------------|
| Can be instantiated | No | Experimental | No | Forbidden | Forbidden | [components/Link.json](components/Link.json) |
## Schema Hierarchy

* Link `http://www.axa.ch/schemas/components/Link.json`
  * [BPMID](../types/bpmid.md) `http://www.axa.ch/schemas/types/bpmid.json`


# Link Properties

| Property | Type | Required | Defined by |
|----------|------|----------|------------|
| [component](#component) | complex | **Required** | Link (this schema) |
| [events](#events) | `array` | Optional | Link (this schema) |
| [name](#name) | BPMID | **Required** | Link (this schema) |
| [properties](#properties) | `object` | Optional | Link (this schema) |
| [style](#style) | `object` | Optional | Link (this schema) |

## component


`component`
* is **required**
* type: complex
* defined in this schema

### component Type


**All** of the following *requirements* need to be fulfilled.


#### Requirement 1


* []() – `http://www.axa.ch/schemas/types/component.json#`


#### Requirement 2







## events
### Events

Supported events of Link.

`events`
* is optional
* type: `array`

* defined in this schema

### events Type


Array type: `array`

All items must be of the type:
Unknown type ``.

```json
{
  "type": "array",
  "title": "Events",
  "description": "Supported events of Link.",
  "uniqueItems": true,
  "additionalItems": false,
  "items": [
    {
      "$ref": "http://www.axa.ch/schemas/types/event.json#"
    }
  ],
  "simpletype": "`array`"
}

name

name

  • is required
  • type: BPMID
  • defined in this schema

name Type

  • BPMID – http://www.axa.ch/schemas/types/bpmid.json#

properties

Properties

Properties of Link.

properties

  • is optional
  • type: object
  • defined in this schema

properties Type

object with following properties:

Property Type Required
href string Optional
value string Optional

href

Href

URL of the Link.

href

  • is optional
  • type: string
href Type

string

value

Value

The value of the Link.

value

  • is optional
  • type: string
value Type

string

style

Style

Styles of Textarea.

style

  • is optional
  • type: object
  • defined in this schema

style Type

object with following properties:

Property Type Required Default
arrow boolean Optional "false"
color string Optional "blue"
listed boolean Optional "false"
motion boolean Optional "false"

arrow

Arrow

Whether or not to display an arrow icon or not.

arrow

  • is optional
  • type: boolean
  • default: "false"
arrow Type

boolean

color

Color

Color of Link.

color

  • is optional
  • type: enum
  • default: "blue"

The value of this property must be equal to one of the known values below.

color Known Values
Value Description
red
white
blue

listed

Listed

Whether or not to us lested style.

listed

  • is optional
  • type: boolean
  • default: "false"
listed Type

boolean

motion

Motion

Whether or not to use animation upon hovering.

motion

  • is optional
  • type: boolean
  • default: "false"
motion Type

boolean

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use OpenAPI "oneOf" property with openapi-generator ...
It handles the same JSON objects though I am not 100% sure it is semanticaly equivalent in OpenAPI specification. Share.
Read more >
JSON Schema references ($ref) - Opis
This keyword is an attempt to create extensible schemas. We do not recommend using it, unless you fully understand its behavior! The value...
Read more >
Schema generation rules · GitBook - Goswagger.Io
We use simple schemas to describe parameters and headers for operations. Simple schemas are supported by go-swagger (including validation), but are not ......
Read more >
The iBench Integration Metadata Generator - VLDB Endowment
mapping composition) that do not depend so directly on the characteristics of a schema hierarchy. Furthermore, this sce- nario generator is limited to...
Read more >
json-schema-faker - npm
Start using json-schema-faker in your project by running `npm i ... required — All required properties are guaranteed, if not can be omitted ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found