Skip to content

Commit

Permalink
Fix OpenAPI generation (#2664)
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd authored Jul 1, 2024
1 parent 3f5c846 commit ad93fc7
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 30 deletions.
Binary file modified compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions compiler/src/model/metamodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class Container extends VariantBase {

export class Untagged extends VariantBase {
kind: 'untagged'
untypedVariant: Inherits
untypedVariant: TypeName
}

/**
Expand All @@ -223,7 +223,7 @@ export class Inherits {
export class Behavior {
type: TypeName
generics?: ValueOf[]
meta?: { [p: string]: string }
meta?: Record<string, string>
}

/**
Expand Down
6 changes: 2 additions & 4 deletions compiler/src/model/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,10 +1129,8 @@ export function parseVariantsTag (jsDoc: JSDoc[]): model.Variants | undefined {
kind: 'untagged',
nonExhaustive: nonExhaustive,
untypedVariant: {
type: {
namespace: fqn.slice(0, fqn.length - 1).join('.'),
name: fqn[fqn.length - 1]
}
namespace: fqn.slice(0, fqn.length - 1).join('.'),
name: fqn[fqn.length - 1]
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/steps/validate-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
throw new Error(`Please contact the devtools team before adding new untagged variant ${fqn(parentName)}`)
}

const untypedVariant = getTypeDef(variants.untypedVariant.type)
const untypedVariant = getTypeDef(variants.untypedVariant)
if (untypedVariant == null) {
modelError(`Type ${fqn(variants.untypedVariant.type)} not found`)
modelError(`Type ${fqn(variants.untypedVariant)} not found`)
}

const items = flattenUnionMembers(valueOf)
Expand Down
18 changes: 6 additions & 12 deletions output/schema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 21 additions & 8 deletions output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typescript-generator/src/metamodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class Container extends VariantBase {

export class Untagged extends VariantBase {
kind: 'untagged'
untypedVariant: Inherits
untypedVariant: TypeName
}

/**
Expand All @@ -223,7 +223,7 @@ export class Inherits {
export class Behavior {
type: TypeName
generics?: ValueOf[]
meta?: { [p: string]: string }
meta?: Record<string, string>
}

/**
Expand Down

0 comments on commit ad93fc7

Please sign in to comment.