Skip to content

Schema for iso3166.CountryCode is not OpenAPI 3.0 compatible (?) #197

@flaeppe

Description

@flaeppe

I have a pydantic model set up like this:

class MyModel(pydantic.BaseModel):
    country_code: CountryCode

Then I run a OpenAPI schema validator against the generated schema found here: https://github.com/p1c2u/openapi-spec-validator

Getting an issue in the anyOf below, on examples. Not sure if it's misplaced?

{
  "type": "string",
  "title": "Alpha2",
  "description": "ISO3166-1 alpha-2 country code",
  "examples": [
    "NR",
    "KZ",
    "ET",
    "VC",
    "AE",
    "NZ",
    "SX",
    "XK",
    "AX"
  ],
  "format": "iso3166-1 alpha-2"
}

Anyways, removing examples from there everything works fine. Perhaps it should move someplace else? I tried moving it on the "root" level of the field object (sibling to anyOf) but that didn't work either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions