Skip to content

Conversation

@charlesbodman
Copy link

This PR fixes an issue with additionalProperties type generation

Input OpenAPI Schema:

"connectionPermissions": {
  "type": "object",
  "additionalProperties": {
    "type": "array",
    "items": {
      "type": "string",
      "enum": ["READ", "UPDATE"]
    }
  }
}

Before Fix

'connectionPermissions': Record<string, unknown>
// or in some cases
'connectionPermissions': { "type": unknown; "items": unknown; }

After Fix

'connectionPermissions': Record<string, Array<'READ' | 'UPDATE'>>
  • Updated the getType function to use a while loop for resolving $ref references.
  • Improved handling of additionalProperties to support recursive types and combined properties.
  • Added tests for various scenarios including additionalProperties with recursive types and multi-level $ref resolution.
  • Modified writeObjectProperties to handle additionalProperties more effectively, including cases for true and object types.
  • Introduced new tests to validate the behavior of writeObjectProperties with complex schemas.

Closes #19

… in schema processing

- Updated the getType function to use a while loop for resolving $ref references.
- Improved handling of additionalProperties to support recursive types and combined properties.
- Added tests for various scenarios including additionalProperties with recursive types and multi-level $ref resolution.

refactor(openapi-common): streamline additionalProperties handling in writeObjectProperties

- Modified writeObjectProperties to handle additionalProperties more effectively, including cases for true and object types.
- Introduced new tests to validate the behavior of writeObjectProperties with complex schemas.
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.

Schemas that references other schemas don't work for some scenarios

1 participant