Skip to content

[org.openapis.v3.contrib] SchemaGenerator does not generate correct title in non-top-level modules #111

@netvl

Description

@netvl

Consider the following modules structure:

// MyApi.pkl

module my_api.MyApi

import "@OpenapisContrib/SchemaGenerator.pkl"

import "Foo.pkl"
import "Bar.pkl"

typealias Variant = Foo | Bar

variant: Variant

output = SchemaGenerator.generate(this).output
// Foo.pkl

module my_api.Foo

foo: String
// Bar.pkl

module my_api.Bar

bar: Int

Running pkl eval MyApi.pkl produces the following schema:

{
  "type": "object",
  "title": "my_api.MyApi",
  "properties": {
    "variant": {
      "title": "Variant",
      "oneOf": [
        {
          "type": "object",
          "title": "ModuleClass",
          "properties": {
            "foo": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "foo"
          ]
        },
        {
          "type": "object",
          "title": "ModuleClass",
          "properties": {
            "bar": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "bar"
          ]
        }
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "variant"
  ]
}

While the properties structure is correct, the title property of Foo and Bar variants of the Variant typealias are wrong: it is ModuleClass instead of my_api.Foo and my_api.Bar, respectively. The root module's title, my_api.MyApi, is correct.

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