openapi generates a valid services/DefaultService.ts:
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import type { Observable } from 'rxjs';
import type { MySQL } from '../models/MySQL';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
@Injectable({
providedIn: 'root',
})
export class DefaultService {
constructor(public readonly http: HttpClient) {}
/**
* Create MySQL resource
* @param requestBody
* @returns MySQL Created
* @throws ApiError
*/
public postDatabaseMysql(
requestBody?: MySQL,
): Observable<MySQL> {
return __request(OpenAPI, this.http, {
method: 'POST',
url: '/mysql',
body: requestBody,
mediaType: 'application/json',
});
}
}
Code with bug
I attached archive openapi-reproduce.zip with valid (without external $ref) and invalid (with external $ref) code. Archive contains openapi-broken project with bug and external $ref, and openapi-valid without bug and external $ref
Problem
openapi.yaml
spec file has relative references to schemasschemas/MySQL.yaml
file (but in our case it doesn't matter):openapi
call generates an invalid Angular client for API:services/DefaultService.ts
is broken:MySQL
model haspaths_1mysql_post_requestBody_content_application_1json_schema
name and that model does't exist (model directory is empty).Without external refs
If i use local ref instead of external everything works fine:
openapi generates a valid
services/DefaultService.ts
:Code with bug
I attached archive openapi-reproduce.zip with valid (without external
$ref
) and invalid (with external$ref
) code. Archive containsopenapi-broken
project with bug and external$ref
, andopenapi-valid
without bug and external$ref