Skip to content

Conversation

@Reykudo
Copy link

@Reykudo Reykudo commented Nov 12, 2022

Hello! I'm trying to implement support discriminator for sum-types.
My way is to call a function that turns inline into a ref, without name clash(by appending _ at end).

@Reykudo Reykudo marked this pull request as draft November 12, 2022 20:39
@Reykudo
Copy link
Author

Reykudo commented Nov 12, 2022

But what to do with the tests, they do not take into account the definitions. For example:

expected:

{
              "oneOf": [
                  {
                      "properties": {
                          "tag": {
                              "enum": [
                                  "ErrorNoUser"
                              ],
                              "type": "string"
                          },
                          "userId": {
                              "maximum": 9223372036854775807,
                              "minimum": -9223372036854775808,
                              "type": "integer"
                          }
                      },
                      "required": [
                          "userId",
                          "tag"
                      ],
                      "type": "object"
                  },
                  {
                      "properties": {
                          "requiredPermission": {
                              "type": "string"
                          },
                          "tag": {
                              "enum": [
                                  "ErrorAccessDenied"
                              ],
                              "type": "string"
                          }
                      },
                      "required": [
                          "requiredPermission",
                          "tag"
                      ],
                      "type": "object"
                  }
              ],
              "type": "object"
          }

but got:

 {
              "discriminator": {
               ^
                  "mapping": {
                      "ErrorAccessDenied": "#/components/schemas/ErrorAccessDenied",
                      "ErrorNoUser": "#/components/schemas/ErrorNoUser"
                  },
                  "propertyName": "tag"
              },
              "oneOf": [
                  {
                      "$ref": "#/components/schemas/ErrorNoUser"
                  },
                  {
                      "$ref": "#/components/schemas/ErrorAccessDenied"
                  }
              ],
              "type": "object"
          }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant