-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[avro-schema] fix: enum logic (sanitize, remove collisions) #19549
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| generatorName: avro-schema | ||
| outputDir: samples/openapi3/schema/valid-enums/avro-schema-enum | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/avro-schema/valid-enums.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/avro-schema |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| openapi: 3.0.0 | ||
| info: | ||
| version: 1.0.0 | ||
| title: Test for valid enums | ||
| paths: | ||
| /test: | ||
| get: | ||
| responses: | ||
| '200': | ||
| description: OK | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/Sample' | ||
| components: | ||
| schemas: | ||
| Sample: | ||
| properties: | ||
| type: | ||
| enum: | ||
| - 'a' | ||
| - 'b' | ||
| # This enum is invalid for Avro schemas, as it contains a `-` | ||
| - 'uh-oh' | ||
| # This next one starts with a number, which is invalid for Avro schemas | ||
| - '0h_oh' | ||
| # The next two is to make sure collisions are resolved properly | ||
| - 'coll-ision' | ||
| - 'coll_ision' | ||
| type: 'string' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # OpenAPI Generator Ignore | ||
| # Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
|
||
| # Use this file to prevent files from being overwritten by the generator. | ||
| # The patterns follow closely to .gitignore or .dockerignore. | ||
|
|
||
| # As an example, the C# client generator defines ApiClient.cs. | ||
| # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
| #ApiClient.cs | ||
|
|
||
| # You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
| #foo/*/qux | ||
| # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
|
||
| # You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
| #foo/**/qux | ||
| # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
|
||
| # You can also negate patterns with an exclamation (!). | ||
| # For example, you can ignore all files in a docs folder with the file extension .md: | ||
| #docs/*.md | ||
| # Then explicitly reverse the ignore rule for a single file: | ||
| #!docs/README.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Sample.avsc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 7.9.0-SNAPSHOT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "namespace": "model", | ||
| "type": "record", | ||
| "doc": "", | ||
| "name": "Sample", | ||
| "fields": [ | ||
| { | ||
| "name": "type", | ||
| "type": ["null", { | ||
| "type": "enum", | ||
| "name": "Sample_type", | ||
| "symbols": [ | ||
| "a", | ||
| "b", | ||
| "uh_oh", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| "_0h_oh", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefixed with |
||
| "coll_ision", | ||
| "coll_ision2" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. count suffix |
||
| ] | ||
| }], | ||
| "doc": "", | ||
| "default": null | ||
| } | ||
| ] | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to express this in unit tests instead if you prefer @sgadouar