OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVASCRIPT] constructFromObject redundantly re-initializes fields belonging to the parent
Personne n'a encore pris cette issue.
- Langage dominant
- Java
- Étoiles
- 26.8k
- Forks
- 7.7k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Description
In MyObject.js :
static constructFromObject(data, obj) {
if (data) {
obj = obj || new MyModel();
BaseModel.constructFromObject(data, obj);
if (data.hasOwnProperty('myProperty')) {
obj['myProperty'] = ApiClient.convertToType(data['myProperty'], 'String');
}
if (data.hasOwnProperty('baseProprty')) {
obj['baseProprty'] = ApiClient.convertToType(data['baseProprty'], 'String');
}
}
return obj;
}
In BaseObject.js :
static constructFromObject(data, obj) {
if (data) {
obj = obj || new BaseModel();
if (data.hasOwnProperty('baseProperty')) {
obj['baseProperty'] = ApiClient.convertToType(data['baseProperty'], 'String');
}
}
return obj;
}
baseProperty is initialized from the call to BaseModel.constructFromObject and then initialized again after the properties unique to the derived object.
openapi-generator version
7.2.0
OpenAPI declaration file content or url
components:
schemas:
BaseModel:
type: object
properties:
baseProperty:
type: string
MyModel:
allOf:
- $ref: "#/components/schemas/BaseModel"
type: object
properties:
myProperty:
type: string
Generation Details
I used the Gradle plugin with the "javascript" generatorName
Steps to reproduce
Define a schema using allOf (without discriminators) and generate JavaScript models.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par les exemples générés de MyObject.js et BaseObject.js et reproduisez le problème en utilisant le schéma allOf fourni avec le générateur JavaScript et le plugin Gradle. Suivez la manière dont constructFromObject gère les propriétés héritées, puis régénérez les modèles pour vérifier que les champs de la classe parente ne sont plus initialisés de manière redondante.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100