OpenAPITools / OpenAPITools/openapi-generator
[BUG][AVRO] object with only additionalProperties is represented with a map with items instead of values property
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/openapi-generator/src/main/resources/avro-schema/typeProperty.mustache and reproduce the issue using resources/test/openapi-spec.yaml with the provided generate command. Compare the generated map schema with valid Avro syntax and verify that the output uses the expected map property.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100