OpenAPITools / OpenAPITools/openapi-generator
[BUG][typescript] Schema format `uri` produces invalid TypeScript
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
The following spec uses schema format uri.
openapi: 3.0.1
info:
title: Foo
description: Bar
version: "2"
paths:
/foo:
get:
parameters:
- name: bar
in: query
schema:
type: string
format: uri
responses:
"200":
description: Ok
The generated TypeScript project contains file apis/DefaultApi.ts which references a non existing URI module like this:
import { URI } from '../models/URI';
For some reason the generator expects a URI type. However, it doesn't create this reference for other custom formats. If the formt is set to i.e. bar then the expected type is string and everything works fine. The format value uri seems to be somewhat special.
I'm using generator version v5.4.0.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the supplied OpenAPI document and generator version v5.4.0, then inspect the generated apis/DefaultApi.ts and the TypeScript generator's handling of the uri format. Compare it with a custom format such as bar. Done means the generated project no longer references a nonexistent models/URI module and the output remains valid TypeScript.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100