-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: manage map types with
additionalProperties
(#98)
* feat: manage additional properties on JSONSchema * test: add sample test for map types * feat: more control when additionalProperties set and Properties set on JSONSchema * feat: allow AdditionalProperties set to true * chore: make gofump happy * test: fix wrong generate query test call Co-authored-by: srdtrk <[email protected]> * feat: add check is additionalProperties doesn't contains object definition --------- Co-authored-by: srdtrk <[email protected]>
- Loading branch information
Showing
5 changed files
with
181 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{ | ||
"contract_name": "map-test", | ||
"contract_version": "0.0.1", | ||
"idl_version": "1.0.0", | ||
"instantiate": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "InstantiateMsg", | ||
"description": "Instantiate message", | ||
"type": "object", | ||
"additionalProperties": false | ||
}, | ||
"execute": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "ExecuteMsg", | ||
"description": "Execute messages", | ||
"oneOf": [ | ||
{ | ||
"title": "Foo", | ||
"type": "object", | ||
"required": [ | ||
"foo" | ||
], | ||
"properties": { | ||
"foo": { | ||
"type": "object", | ||
"additionalProperties": false | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
] | ||
}, | ||
"query": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "QueryMsg", | ||
"description": "Query messages", | ||
"oneOf": [ | ||
{ | ||
"title": "MapString", | ||
"type": "object", | ||
"required": [ | ||
"map_string" | ||
], | ||
"properties": { | ||
"map_string": { | ||
"type": "object", | ||
"required": [ | ||
"foo" | ||
], | ||
"properties": { | ||
"foo": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"map_with_value" | ||
], | ||
"properties": { | ||
"map_with_value": { | ||
"type": "object", | ||
"required": [ | ||
"foo" | ||
], | ||
"properties": { | ||
"foo": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"$ref": "#/definitions/Value" | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
], | ||
"definitions": { | ||
"Value": { | ||
"type": "object", | ||
"required": [ | ||
"value" | ||
], | ||
"properties": { | ||
"value": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
} | ||
}, | ||
"migrate": null, | ||
"sudo": null, | ||
"responses": { | ||
"map_string": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "BarResponse", | ||
"type": "object", | ||
"required": [ | ||
"foo" | ||
], | ||
"properties": { | ||
"foo": { | ||
"description": "The foo value", | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"map_with_value": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "BarResponse", | ||
"type": "object", | ||
"required": [ | ||
"foo" | ||
], | ||
"properties": { | ||
"foo": { | ||
"description": "The foo value", | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"description": "# map-test", | ||
"title": "map-test" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters