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

Closed
meandus opened this issue Apr 30, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@meandus
Copy link

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

@samuelcolvin

This comment has been minimized.

Copy link
Owner

commented Apr 30, 2019

Probably needs implementing. PR welcome.

@pilosus

This comment has been minimized.

Copy link
Contributor

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('192.168.0.0/24'))

try:
    m.schema()
except ValueError as e:
    print(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} (#532)
* Fix to schema generation for IPv{4,6}{Address,Interface,Network}, fix #498

* Added docs

* Added PR number

* Updated format to comply with http://json-schema.org/latest/json-schema-validation.html#rfc.section.7.3.4
Modified tests accordingly

* For real

gangefors added a commit to gangefors/pydantic that referenced this issue May 31, 2019

Merge remote-tracking branch 'upstream/master'
* upstream/master: (138 commits)
  add 'none-any.whl' to pypi upload (samuelcolvin#564)
  uprev
  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)
  uprev.
  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)
  uprev
  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
You can’t perform that action at this time.