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

feat: unit test and linting for cts generation APIC-277 #103

Merged
merged 2 commits into from
Jan 25, 2022
Merged

Conversation

millotp
Copy link
Collaborator

@millotp millotp commented Jan 25, 2022

🧭 What and Why

🎟 JIRA Ticket: APIC-277

Changes included:

  • Check the linting for generation script in the CI
  • Add unit test to the generation script
  • Format the script at the end of generation to save time
  • Clean up types for requests
  • Recursive augmentation of parameters

🧪 Test

CI

@millotp millotp requested a review from a team January 25, 2022 13:45
@millotp millotp self-assigned this Jan 25, 2022
@millotp millotp requested review from eunjae-lee and removed request for a team January 25, 2022 13:45
@@ -3,9 +3,143 @@ import fsp from 'fs/promises';
import SwaggerParser from '@apidevtools/swagger-parser';
import type { OpenAPIV3 } from 'openapi-types';

import { removeObjectName, walk } from '../../utils';
import { removeEnumType, removeObjectName, walk } from '../../utils';
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain to me what this enum type thing is? is it java related? if it is, what if we split data processing part per language? because this seems irrelevant to JS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not just enum related, this will take all arguments like:

{
  "test1": "hello",
  "other": [{
    "test2": 4
  }]
}

And convert it to:

{
  "test1": {
    "value": "hello",
    "isArray": false,
    "isObject": false,
    "isInteger": false,
    "isString": true,
    ...
  },
  "other": {
    "value": [{
      "value": {
        "test2": {
           "value": 4,
           "isArray": false,
          "isObject": false,
          "isInteger": true,
          "isString": false,
          ...
        },
        "isArray": false,
        "isObject": true,
        "isInteger": false,
       "isString": false,
        ...
      },
      "isArray": false,
      "isObject": true,
      "isInteger": false,
      "isString": false,
      ...
    }],
    "isArray": true,
     "isObject": false,
     "isInteger": false,
     "isString": false,
      ...
  }
}

recursively, which is the common way to handle complex objects in mustache (openapi does the same augmentation).
This attribute parametersWithDataType will be the one used in all typed languages, the exception is actually js that don't need all that and can do fine just with the json representation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I saw that adds a bunch of helper variables for mustache. I was just wondering what removeEnumType function does :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's to remove all type decoration and leave raw json, for languages that don't support enum or don't need them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants