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

properties' custom_formatters don't work unless the containing shema is strictly Object

Abierto
#149 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
openapi, python

Línea de trabajo

Start with _unmarshal_any and its call to get_cast_mapping, then trace how custom_formatters and custom validators are propagated for SchemaType.ANY. Reproduce the MediaType example with the url format and verify that custom formatting and validation work for properties within an ANY schema.

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

Descripción

Found this issue while investigating the code for #147

I noticed that custom_formatters are not being user for unmarshalling and validating properties, unless their containing Schema is strictly defined.

That is, if the Schema is of type SchemaType.ANY, custom_validators will not work. That's because the _unmarshal_any object fails to propagate the attributes to get_cast_mapping:

def _unmarshal_any(self, value, custom_formatters=None, strict=True):
    types_resolve_order = [
        SchemaType.OBJECT, SchemaType.ARRAY, SchemaType.BOOLEAN,
        SchemaType.INTEGER, SchemaType.NUMBER, SchemaType.STRING,
    ]
    cast_mapping = self.get_cast_mapping()

    ...

This is specifically sensitive for defining MediaType objects:

paths:
  /test:
    get:
      operationId: test
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/DefaultResponse'
components:
  schemas:
    DefaultResponse:
      type: object
      properties:
        url:
          type: string
          format: url

The shema type for that MediaType will be Any (See #147), so that 'url' format will not unmarshal, even though you may define a custom formatter.

Lenguaje dominante
Python
Estrellas
368
Forks
140
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

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 python-openapi/openapi-core

Todos los issues de python-openapi/openapi-core

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.