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

[BUG][AVRO] object with only additionalProperties is represented with a map with items instead of values property #20566

Open
5 of 6 tasks
npfp opened this issue Jan 31, 2025 · 0 comments

Comments

@npfp
Copy link

npfp commented Jan 31, 2025

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating avro schema associated to an openapi spec that contains an object with only additionalProperties set, the avro schema generated is not valid:

      "type": ["null", {
        "type": "map",
        "items": "string"
      }],

where it should be

      "type": ["null", {
        "type": "map",
        "values": "string"
      }],
openapi-generator version
openapi-generator-cli 7.10.0
  commit : 12dfe8f
OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Sample API
  description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
  version: 0.1.9

servers:
  - url: http://api.example.com/v1
    description: Optional server description, e.g. Main (production) server
  - url: http://staging-api.example.com
    description: Optional server description, e.g. Internal staging server for testing

paths:
  /users:
    get:
      summary: Returns a list of users.
      description: Optional extended description in CommonMark or HTML.
      responses:
        "200": # status code
          description: A JSON array of user names
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
components:
  schemas:
    Alert:
      type: object
      properties:
        tags:
          type: object
          description: Label-Value Pairs to identify properties about an alert
          additionalProperties:
            type: string
          example:
            cluster: prod
            type: unexpected_shutdown
Steps to reproduce
openapi-generator-cli generate -g avro-schema -i resources/test/openapi-spec.yaml -o test
Suggest a fix

I suppose it's related to

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/avro-schema/typeProperty.mustache

or at least that could be fixed by a new template but know about nothing about the way it works. I'd be happy to try to fix it if you could give me some pointers.

Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant