ajevans99 / swift-json-schema

Generate JSON Schema documents from Swift
MIT License
12 stars 5 forks source link

Missing public initializer of RootSchema #25

Closed ptrkstr closed 2 months ago

ptrkstr commented 2 months ago

Hey @ajevans99 👋 I'm following along with the documentation and it appears a consumer of the package is not able to initialize a RootSchema as there doesn't appear to be a public initializer (given that the automatic synthesized initializer is only internal)

let schema = RootSchema(
  id: "https://example.com/person.schema.json",
  schema: "https://json-schema.org/draft/2020-12/schema",
  subschema: .object(
    .annotations(title: "Person"),
    .options(
      properties: [
        "firstName": .string(
          .annotations(description: "The person's first name.")
        ),
        "lastName": .string(
          .annotations(description: "The person's last name.")
        ),
        "age": .integer(
          .annotations(description: "Age in years which must be equal to or greater than zero."),
          .options(minimum: 0)
        )
      ]
    )
  )
)
ajevans99 commented 2 months ago

Oops. Good call. Created PR to fix. I'll release as v0.2.1 on top of 0.2.0 because of some pretty major changes on main for v0.3.0.