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.

`additionalProperties` doesn't work properly with `$ref`

See original GitHub issue

Consider the following:

openapi: 3.0.1
info:
  title: Whatever
  version: 1.0.0
paths:
  /foo:
    post:
      operationId: getFoo
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Foo'
components:
  schemas:
    Foo:
      type: object
      required:
        - something
        - props
      properties:
        something:
          type: string
        props:
          type: object
          additionalProperties:
            type: integer
            format: int32
    FooProps:
      type: object
      additionalProperties:
        type: integer
        format: int32
    FooNested:
      type: object
      required:
        - something
        - props
      properties:
        something:
          type: string
        props:
          $ref: "#/components/schemas/FooProps"

Foo comes out correct:

case class Foo(something: String, props: Map[String, Int])

However, I would expect FooNested to look the same, but instead we get:

case class FooNested(something: String, props: io.circe.Json)

(And FooProps isn’t emitted at all, as I guess we’d expect.)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kelnoscommented, May 4, 2019
0reactions
kelnoscommented, May 4, 2019

Yah, I’m working on a test now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

additionalProperties and $ref are not working together #185
I have a schema file (Thing.schema) which is referencing to another file (ID.schema). When I set inside of Thing.schema ...
Read more >
how to use additionalProperties from a $ref file? - Stack Overflow
additionalProperties: false works by applying false (which is a valid schema, which returns failure to validate) to values which do not ...
Read more >
"additionalProperties" and "allOf", here we go again!
talking about. ... So the end result is a schema where the data must be an object, and the "foo" property (if defined)...
Read more >
Understanding JSON Schema
JSON Schema is a powerful tool for validating the structure of JSON data. However, learning to use it by reading its.
Read more >
Additional Properties - Liquid Technologies
The value of "additionalProperties" MUST be a boolean or an object. ... For each regex in "pp", if it matches "m" successfully, the...
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