Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Typescript-Node] Mark deprecated endpoints #19770

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export class {{classname}} {
{{#allParams}}
* @param {{paramName}} {{description}}
{{/allParams}}
{{#isDeprecated}}
*
* @deprecated
Copy link
Contributor

@joscha joscha Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you had tabs. If you use spaces to indent it, it should work. My suggestion removed the tab.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @deprecated
* @deprecated

This should work, it's tricky in the webinterface :)

{{/isDeprecated}}
*/
public async {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; {{#returnType}}body: {{{.}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> {
const localVarPath = this.basePath + '{{{path}}}'{{#pathParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,26 @@ public void testDeprecatedAttribute() throws IOException {
"* @deprecated");
}

@Test
public void testDeprecatedOperation() throws IOException {

File output = Files.createTempDirectory("typescriptnodeclient_").toFile();
output.deleteOnExit();

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("typescript-node")
.setInputSpec("src/test/resources/3_0/typescript-node/SampleProject.yaml")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

final ClientOptInput clientOptInput = configurator.toClientOptInput();
DefaultGenerator generator = new DefaultGenerator();
List<File> files = generator.opts(clientOptInput).generate();
files.forEach(File::deleteOnExit);

TestUtils.assertFileContains(Paths.get(output + "/api/defaultApi.ts"),
"* @deprecated");
}

private OperationsMap createPostProcessOperationsMapWithImportName(String importName) {
OperationMap operations = new OperationMap();
operations.setClassname("Pet");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ paths:
patch:
summary: Update User Information
operationId: patch-users-userId
deprecated: true
responses:
'200':
description: User Updated
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/typescript-node/3_0/api/defaultApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export class DefaultApi {
* @param strCode Code as header
* @param strCode2 Code as header2
* @param patchUsersUserIdRequest Patch user properties to update.
*
* @deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

*/
public async patchUsersUserId (userId: number, strCode?: string, strCode2?: string, patchUsersUserIdRequest?: PatchUsersUserIdRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: User; }> {
const localVarPath = this.basePath + '/users/{userId}'
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/typescript-node/default/api/petApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ export class PetApi {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @summary Finds Pets by tags
* @param tags Tags to filter by
*
* @deprecated
*/
public async findPetsByTags (tags: Array<string>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<Pet>; }> {
const localVarPath = this.basePath + '/pet/findByTags';
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/typescript-node/npm/api/petApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ export class PetApi {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @summary Finds Pets by tags
* @param tags Tags to filter by
*
* @deprecated
*/
public async findPetsByTags (tags: Array<string>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<Pet>; }> {
const localVarPath = this.basePath + '/pet/findByTags';
Expand Down
Loading