Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

How to replace the value list of an array?

Abierto
#30 18 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Documentación
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
yaml

Línea de trabajo

Comienza con la sección Action Object de la Overlay Specification y compara su redacción sobre la combinación con los ejemplos proporcionados de OpenAPI y Overlay YAML. Confirma si actualizar x-bar debe reemplazar o añadir elementos al array, y documenta el comportamiento previsto o la solución alternativa de remove-and-readd en la Specification.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

I want to replace the value list of an array with a new list of values. However, the two overlay implementations I've tried treat the following example as "append to an array" rather than "replace an array".

I'm not sure if the implementation behavior is correct or a bug, so wanted to confirm the intended behavior with the spec authors.


OpenAPI document:

openapi: 1.0.0
info:
  title: Array replacement test
  version: 1.0.0
paths: {}
x-foo:
  x-bar:  # I want to replace all values of this array
    - 1
    - 2

Overlay:

overlay: 1.0.0
info:
  title: Array replacement test
  version: 0.0.1
extends: array-test.yaml

actions:
  - target: $['x-foo']
    update:
      x-bar:
        - 3
        - 4

The Action Object section says:

When the Overlay document is applied, the properties in the merge object replace properties in the target object with the same name

I understand this as x-foo being the "merge object", x-bar being a "property in the merge object", so the x-bar value from the overlay should replace (and not be appended to) the x-bar value in the document.


The workaround is to remove the array node then re-add it with the new values. This seems a bit verbose, but if that's the intended way to replace arrays then I'm OK with it.

actions:
  - target: $['x-foo']['x-bar']
    remove: true

  - target: $['x-foo']
    update:
      x-bar:
        - 3
        - 4
Lenguaje dominante
JavaScript
Estrellas
123
Forks
38
Merge medio
3 d 22 h
PR fusionados (30 d)
11

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de OAI/Overlay-Specification

Todos los issues de OAI/Overlay-Specification

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.