openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

Local refs are misinterpreted as external refs because they are not unescaped

Open richard-fairthorne opened this issue 3 years ago • 0 comments

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:

Screen Shot 2022-05-19 at 9 21 06 AM

Swagger ref docs

richard-fairthorne avatar May 19 '22 13:05 richard-fairthorne