Skip to content

feb 22 update #779

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

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Changes from all 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
43 changes: 21 additions & 22 deletions FETCH_MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Fetch was selected as the new HTTP request library for this project due to its w

For more details see the initial discussion ([#754](https://github.com/kubernetes-client/javascript/issues/754)).

Edit 02/2022:

Since the OpenApiGenerator project is targeting a single `typescript` generator (instead of individual networking flavors eg: typescript-fetch, typescript-axios) that includes node-fetch support, the initial plans to import and inject node-fetch is no longer optimal.

The proposed changes have been implemented on the new `typescript` generator which includes changes to the authentication and authorization interface that now uses a `RequestContext` object instead of directly allowing access to the https request options. In order to bridge the existing javascript client auth methods, additional exposure via custom SecurityAuthentication support has [been merged](https://github.com/OpenAPITools/openapi-generator/pull/11321) into the typescript generator.


## Release cycle

The fetch generator will create breaking changes to this project's API. Consumers will have to make small modifications to their code to upgrade.
Expand Down Expand Up @@ -40,31 +47,23 @@ Code will be on the `master` branch.
### Other repositories

- [x] Update [kubernetes-client/gen](https://github.com/kubernetes-client/gen)'s typescript-fetch files to let us pass in the `typescriptThreePlus` config option <sup>[1](https://github.com/OpenAPITools/openapi-generator/issues/9973) [2](https://github.com/OpenAPITools/openapi-generator/issues/3869#issuecomment-584152932)</sub>
- [ ] Update [openapi-generator](https://github.com/OpenAPITools/openapi-generator)'s typescript-fetch flavor to mark parameters as optional if all parameters are optional <sup>[3](https://github.com/OpenAPITools/openapi-generator/issues/6440)</sup>
- [x] Update [openapi-generator](https://github.com/OpenAPITools/openapi-generator)'s typescript-fetch flavor to mark parameters as optional if all parameters are optional <sup>[3](https://github.com/OpenAPITools/openapi-generator/issues/6440)</sup>

### Kubernetes-client repository

- [ ] Increment `OPENAPI_GENERATOR_COMMIT` to be [version 5.3.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.3.0) (with the optional parameters addition)
- [ ] `npm install node-fetch` to install node-fetch
- [ ] Switch generate-client script to use typescript-fetch
- [ ] Import and inject node-fetch in `src/api.ts` with the following

```typescript
import fetch from 'node-fetch';

// inject node-fetch
if (!globalThis.fetch) {
// @ts-ignore
globalThis.fetch = fetch;
globalThis.Headers = Headers;
globalThis.Request = Request;
globalThis.Response = Response;
}
```

- [ ] Generate api with `npm run generate`
- [ ] Match src/gen/api.ts to new generated layout (it changes slightly)
- [ ] Fix errors in /src folder (due to new api)
- [x] Increment `OPENAPI_GENERATOR_COMMIT` to be [version 5.3.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.3.0) (with the optional parameters addition)
- [x] `npm install node-fetch` to install node-fetch
- [ ] ~~Switch generate-client script to use typescript-fetch~~ (see edit 02/2022)
- [ ] ~~Import and inject node-fetch in `src/api.ts`~~ (see edit 02/2022)

- [x] Generate api with `npm run generate`
- [x] Match src/gen/api.ts to new generated layout (it changes slightly)

- [ ] Fix errors in /src folder (due to new generated api)
- [ ] Migrate watch.ts to use node-fetch
- [ ] Migrate log.ts to use node-fetch
- [ ] Migrate metrics.ts to use node-fetch
- [ ] Migrate HttpError Usage to HttpException (following new OpenApiGen convention)
- [ ] Fix errors in test (due to new api)
- [ ] Test all features
- [ ] Fix examples (due to new api)
Expand Down