Skip to content

OpenAPI v3 Specification errors #18

@luis199230

Description

@luis199230

I installed the following libraries

chalice==1.28.0
apispec==6.3.0
chalice_spec==0.6.0
pydantic==2.0.3

My initialization code is this:

spec = APISpec(
    title='test-with-openapi-v3',
    version='1.0.0',
    openapi_version="3.0.2",
    plugins=[
        PydanticPlugin()
    ]
)

spec.components.schema("CodeSchema", model=CodeSchema)
spec.components.schema("CodesResponse", model=CodesResponse)

my CodeSchema:

class CodeSchema(BaseModel):
    id: str
    status: str
    person: str = 'uuid'

my CodesResponse:

class CodesResponse(BaseModel):
    status: bool
    message: str
    data: List[CodeSchema]

When I validate in https://validator.swagger.io/validator/debug my url
I find this error:

{
  "messages": [
    "attribute components.schemas.CodesResponse.$defs is unexpected"
  ],
  "schemaValidationMessages": [
    {
      "level": "error",
      "domain": "validation",
      "keyword": "oneOf",
      "message": "instance failed to match exactly one schema (matched 0 out of 2)",
      "schema": {
        "loadingURI": "#",
        "pointer": "/definitions/Components/properties/schemas/patternProperties/^[a-zA-Z0-9\\.\\-_]+$"
      },
      "instance": {
        "pointer": "/components/schemas/CodesResponse"
      }
    }
  ]
}

I was researching and I realized in OpenAPI v3 not support that reference and I would like to know if possible to solve from your side or apisec side?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions