[BUG] ExampleGenerator returns the string "{}" (or null) for `type: object` schemas without `properties`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Individua resolvePropertyToExample e resolveModelToExample nel codice Java che implementa ExampleGenerator; l’issue non indica il loro file né un test. Inizia riproducendo il problema con lo schema OpenAPI fornito e verificando come vengono gestiti i valori $ref non risolti. Il lavoro è completato quando gli schemi oggetto senza proprietà producono un oggetto JSON vuoto sia negli esempi annidati sia in quelli di primo livello, anziché una stringa o null.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- 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?
Description
resolvePropertyToExample returns the Java string literal "{}" for an object schema without properties and for a $ref that cannot be resolved. Json.pretty then serializes it as a JSON string ("metadata" : "{}") instead of an empty object ("metadata" : { }), so the example has the wrong type (JSON Schema Validation wright-00, 5.21).
The same happens one level up. For a top-level model type: object without properties, resolveModelToExample falls through to return null, and generate(null, ["application/json"], "Anything") returns the example null. Through the CLI this model gets unaliased first, so the operation simply has no example; only programmatic callers see null.
openapi-generator version
7.25.0 (also current master).
OpenAPI declaration file content or url
components:
schemas:
Reading:
type: object
properties:
metadata:
type: object
Steps to reproduce
generate -g html → "Example data" shows "metadata" : "{}". Expected: "metadata" : { }.
Suggest a fix
Return new LinkedHashMap<>() (an empty map) instead of the string "{}" in both branches of resolvePropertyToExample, and also for object schemas without properties in resolveModelToExample.
- Lingua principale
- Java
- Stelle
- 26.8k
- Fork
- 7.7k
- Merge medio
- 1g 12h
- PR unite (30g)
- 141
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di OpenAPITools/openapi-generator
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
OpenAPITools/openapi-generator#25236 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] OpenApiEvaluator reports "default value not in enum" for numerically equal values with different scale (e.g. 1.5 and 1.50)Forse già presa @mohitduhan19 l’ha presa oggi. ApertaIssue: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
OpenAPITools/openapi-generator#25233 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] OpenApiEvaluator emits "Unused model" warnings even when recommendations are disabledForse già presa @mohitduhan19 l’ha presa oggi. ApertaIssue: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
OpenAPITools/openapi-generator#25232 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG][KOTLIN] multiplatform/jvm-ktor: `DELETE` without `requestBody` sends `"Content-Type: application/json"` with an empty bodyForse già presa @mohitduhan19 l’ha presa oggi. ApertaIssue: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
OpenAPITools/openapi-generator#25223 ·
I maintainer di solito rispondono entro 1 giorno
-
Issue: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
OpenAPITools/openapi-generator#25218 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di OpenAPITools/openapi-generator
Issue simili
-
:ml/Transform >bug Team:ML
Difficoltà 2/5 Mezza giornata Idoneità per principianti 64/100
elastic/elasticsearch#161960 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Tiviacz1337/Travelers-Backpack#1629 ·
-
bug: Authentication and App Check listeners leak the Activity and WebView on AndroidForse già presa @harbinzhang l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
capawesome-team/capacitor-firebase#1050 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
capawesome-team/capacitor-plugins#1134 ·
I maintainer di solito rispondono entro 1 giorno