This repository was archived by the owner on Jun 30, 2023. It is now read-only.
Generate proper API description for Map types using "additionalProperties"#155
Merged
tangiel merged 9 commits intocloudendpoints:masterfrom Sep 19, 2018
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #155 +/- ##
============================================
+ Coverage 80.12% 80.26% +0.13%
- Complexity 1689 1711 +22
============================================
Files 157 158 +1
Lines 5629 5684 +55
Branches 735 748 +13
============================================
+ Hits 4510 4562 +52
- Misses 838 840 +2
- Partials 281 282 +1
Continue to review full report at Codecov.
|
14c1d58 to
ee0b460
Compare
Contributor
|
Looks like there is a conflict now (may have merged out of order) |
added 6 commits
August 27, 2018 20:13
- Two unit tests disabled (to reenable) - Missing flag to enable new map handling - Changed description handling in SwaggerGenerator to follow spec
- Enable new behaviour with a property / env flag - Still use JsonMap for unsupported keys (not String) or value types (arrays) - Add a flag to warn about unsupported Map type parameters - Reenable disabled tests (now passing) - Test old and new behaviour in unit tests
- Support additional map key types (confirmed to work at runtime) - Add new flag to enable support for array-like value types - ALlow to use warn flag without actually generating new schema for Maps - Add Javadoc on flags for maps - Additional test cases for Map types
- Improve Map schema-related flags with dedicated MapSchemaFlag class - Default to Map schema using "additionalProperties", with flag for legacy mode - Fail by default when encountering non-String Map keys, with flag to ignore - Improve unit tests
- Handle subclasses of Map with concrete key and value (exclude others) - Exclude raw Map type - Better support nested Maps
ee0b460 to
1e573c8
Compare
Contributor
Author
|
I rebased from latest master (conflict was only in imports). |
tangiel
reviewed
Sep 4, 2018
endpoints-framework/src/main/java/com/google/api/server/spi/config/model/MapSchemaFlag.java
Show resolved
Hide resolved
endpoints-framework/src/main/java/com/google/api/server/spi/config/model/SchemaRepository.java
Show resolved
Hide resolved
| } | ||
|
|
||
| @Test | ||
| public void testWriteDiscovery_MapEndpoint_InvalidKeyTypeKO() throws Exception { |
Contributor
Author
There was a problem hiding this comment.
It is, but I will make the name more explicit.
| @@ -0,0 +1,121 @@ | |||
| /* | |||
| * Copyright 2016 Google Inc. All Rights Reserved. | |||
Contributor
There was a problem hiding this comment.
Let's keep the year up to date on new files.
Contributor
Author
|
I fixed formatting and copyright issues. |
tangiel
approved these changes
Sep 19, 2018
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes the way Cloud Endpoints handles Map types when generating API specs:
This introduces backward incompatible changes to the generated Java clients, and the stricter validation of acceptable Map types can make some APIs fail to generate the spec.
Legacy behavior can be reintroduced for both of these using flags in MapSchemaFlag (see FORCE_JSON_MAP_SCHEMA and IGNORE_UNSUPPORTED_KEY_TYPES).
A note about Map types with array-like values:
I previously opened an issue about this: #142