Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#149 2 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
45/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
openapi, python

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
368
Forks
140
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de python-openapi/openapi-core

Todas as issues de python-openapi/openapi-core

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.