openapi-typescript-codegen
openapi-typescript-codegen copied to clipboard
Local refs are misinterpreted as external refs because they are not unescaped
When trying to process the kraken openapi spec, $ref's are misinterpreted as being external.
For example:
{ "$ref": "#/paths/~1private~1Stake/post/responses/200/content/application~1json/schema/properties/error" }
is an internal reference to "/private/Stake", but because the escape sequence '~1', which represents a forward slash, is not unescaped in processing, the reference is not found, and an invalid import is generated:
import type { paths_1private_1Stake_post_responses_200_content_application_1json_schema_properties_error } from '../models/paths_1private_1Stake_post_responses_200_content_application_1json_schema_properties_error';
Expected behaviour:
~0 and ~1 should be properly unescaped and the reference should be treated as local.
The correct behaviour is described in the swagger docs: