Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialization of ipvanynetwork / ipvanyaddress to json schema #498

meandus opened this issue Apr 30, 2019 · 2 comments

serialization of ipvanynetwork / ipvanyaddress to json schema #498

meandus opened this issue Apr 30, 2019 · 2 comments


Copy link

@meandus meandus commented Apr 30, 2019

on 0.24 is it possible to serialize json for ipvanyaddress and ipvanynetwork ? cause now impossible to serialize correctly ipvanynetwork through fastapi models

Copy link

@samuelcolvin samuelcolvin commented Apr 30, 2019

Probably needs implementing. PR welcome.

Copy link

@pilosus pilosus commented May 7, 2019

It looks like I forgot to add .schema() support in #333 alhtough it was documented :-/

from pydantic import BaseModel, IPvAnyNetwork
from ipaddress import IPv4Address, IPv6Address, IPv4Interface, IPv6Interface, IPv4Network, IPv6Network                                                                                              

class Model(BaseModel): 
    ip_network: IPvAnyNetwork = None 

m = Model(ip_network=IPv4Network(''))

except ValueError as e:
# > Value not declarable with JSON Schema, field: ip_v4_network type=IPv4Network default=None

@meandus If you didn't start to work on this issue then I'll try to fix it

pilosus added a commit to pilosus/pydantic that referenced this issue May 7, 2019
samuelcolvin added a commit that referenced this issue May 21, 2019
* Fix to schema generation for IPv{4,6}{Address,Interface,Network}, fix #498

* Added docs

* Added PR number

* Updated format to comply with
Modified tests accordingly

* For real
gangefors added a commit to gangefors/pydantic that referenced this issue May 31, 2019
* upstream/master: (138 commits)
  add 'none-any.whl' to pypi upload (samuelcolvin#564)
  update benchmarks (samuelcolvin#563)
  cython (samuelcolvin#548)
  Fix issue with unspecified generic type (samuelcolvin#554)
  Run dataclass' original __post_init__ before validation (samuelcolvin#560)
  try to stop annoying warnings in azure pipeline (samuelcolvin#549)
  azure pipeline failOnStderr: false
  Azure Pipelines - tests for windows (samuelcolvin#538)
  Fix JSON Schema for list, tuple, and set, improving interoperability (samuelcolvin#540)
  Colors (samuelcolvin#516)
  Fix to schema generation for IPv{4,6}{Address,Interface,Network} (samuelcolvin#532)
  Fix __fields_set__ not using alias field names (samuelcolvin#517) (samuelcolvin#518)
  Change return type hint for create_model (samuelcolvin#526)
  Tuple ellipsis (samuelcolvin#512)
  Fix to schema generation for IPvAny{Address,Interface,Network} (samuelcolvin#498) (samuelcolvin#510)
  Scheduled monthly dependency update for May (samuelcolvin#499)
  Implement const keyword in Schema. (samuelcolvin#469)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants