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

Json Schema doesn't support additionalProperties as expected #8069

Closed
madhavmurthy93 opened this issue May 19, 2020 · 3 comments · Fixed by #8848
Closed

Json Schema doesn't support additionalProperties as expected #8069

madhavmurthy93 opened this issue May 19, 2020 · 3 comments · Fixed by #8848
Assignees
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug. p2

Comments

@madhavmurthy93
Copy link
Contributor

The definition of additional properties is:
The additionalProperties keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the properties keyword. By default any additional properties are allowed.

The additionalProperties keyword may be either a boolean or an object. If additionalProperties is a boolean and set to false, no additional properties will be allowed.

If additionalProperties is an object, that object is a schema that will be used to validate any additional properties not listed in properties.

Reference: https://json-schema.org/understanding-json-schema/reference/object.html#properties

When I try to use it as described above:

capabilityValues: {
    type: JsonSchemaType.OBJECT,
    additionalProperties: {
        type: [JsonSchemaType.STRING, JsonSchemaType.NUMBER, JsonSchemaType.BOOLEAN]
    }
}

I get the following error

error TS2322: Type '{ type: JsonSchemaType[]; }' is not assignable to type 'boolean | undefined'.
  Type '{ type: JsonSchemaType[]; }' is not assignable to type 'true'.

91                                 additionalProperties: {
                                   ~~~~~~~~~~~~~~~~~~~~

Code reference:

readonly additionalProperties?: boolean;

@SomayaB SomayaB added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label May 19, 2020
@SomayaB SomayaB added the guidance Question that needs advice or information. label May 19, 2020
@nija-at
Copy link
Contributor

nija-at commented May 27, 2020

Re-classifying this as a bug.

@nija-at nija-at added bug This issue is a bug. p2 and removed guidance Question that needs advice or information. labels May 27, 2020
@nikolajwestergaard
Copy link

nikolajwestergaard commented Jun 3, 2020

Any reason why was supporting JsonSchema as additionalProperties removed in september 2019? See: #3997
Using additionalProperties seems to be part of the Json Schema standard and part of the Swagger / OpenAPI standard (https://swagger.io/docs/specification/data-models/dictionaries/).
It's pretty importing if the serving of dictionaries or indexes of complex data.

@madhavmurthy93
Copy link
Contributor Author

@nikolajwestergaard yes definitely important for defining dictionaries and we need support for that right now. @nija-at any update on when this will get worked on?

@mergify mergify bot closed this as completed in #8848 Aug 3, 2020
mergify bot pushed a commit that referenced this issue Aug 3, 2020
…Schema type (#8848)

As per: https://json-schema.org/understanding-json-schema/reference/object.html, the additionalProperties can be boolean or JsonSchema.

JsonSchema was previously supported by APIGateway but It was removed for some reason here: 73a1de1.

fixes #8069

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
curtiseppel pushed a commit to curtiseppel/aws-cdk that referenced this issue Aug 11, 2020
…Schema type (aws#8848)

As per: https://json-schema.org/understanding-json-schema/reference/object.html, the additionalProperties can be boolean or JsonSchema.

JsonSchema was previously supported by APIGateway but It was removed for some reason here: aws@73a1de1.

fixes aws#8069

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug. p2
Projects
None yet
4 participants