vite-plugin-openapi-codegen 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -670,9 +670,9 @@ function readSecurityRequirement(entry, securitySchemes, topLevelSecurity) {
670
670
  const requirement = security[0];
671
671
  if (!isRecord(requirement)) throw new Error(`Operation "${entry.operationId}" has an invalid security requirement`);
672
672
  for (const [schemeName, scopes] of Object.entries(requirement)) {
673
- const type = securitySchemes?.[schemeName]?.type;
674
- if (type === "apiKey") return { kind: "internal" };
675
- if (type === "http") {
673
+ const scheme = securitySchemes?.[schemeName];
674
+ if (scheme?.type === "apiKey" && scheme.in === "header") return { kind: "internal" };
675
+ if (scheme?.type === "http" || scheme?.type === "apiKey" && scheme.in === "cookie") {
676
676
  const roles = Array.isArray(scopes) ? scopes.filter((scope) => typeof scope === "string") : [];
677
677
  return roles.length === 0 ? { kind: "authenticated" } : {
678
678
  kind: "role",
package/dist/index.d.mts CHANGED
@@ -30,6 +30,8 @@ type OpenAPISecurityRequirement = Record<string, string[]>;
30
30
  interface OpenAPISecurityScheme {
31
31
  type?: string;
32
32
  scheme?: string;
33
+ in?: string;
34
+ name?: string;
33
35
  }
34
36
  interface OpenAPIOperation {
35
37
  operationId?: string;
package/dist/index.mjs CHANGED
@@ -668,9 +668,9 @@ function readSecurityRequirement(entry, securitySchemes, topLevelSecurity) {
668
668
  const requirement = security[0];
669
669
  if (!isRecord(requirement)) throw new Error(`Operation "${entry.operationId}" has an invalid security requirement`);
670
670
  for (const [schemeName, scopes] of Object.entries(requirement)) {
671
- const type = securitySchemes?.[schemeName]?.type;
672
- if (type === "apiKey") return { kind: "internal" };
673
- if (type === "http") {
671
+ const scheme = securitySchemes?.[schemeName];
672
+ if (scheme?.type === "apiKey" && scheme.in === "header") return { kind: "internal" };
673
+ if (scheme?.type === "http" || scheme?.type === "apiKey" && scheme.in === "cookie") {
674
674
  const roles = Array.isArray(scopes) ? scopes.filter((scope) => typeof scope === "string") : [];
675
675
  return roles.length === 0 ? { kind: "authenticated" } : {
676
676
  kind: "role",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-openapi-codegen",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "description": "Vite plugin that generates typed API clients and route builders from OpenAPI specs",
5
5
  "keywords": [
6
6
  "api-client",