Skip to content

Commit

Permalink
Expand snapshot repository types (#2255)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshMock authored and swallez committed Mar 6, 2024
1 parent ce97fb5 commit a66fc61
Show file tree
Hide file tree
Showing 5 changed files with 867 additions and 138 deletions.
6 changes: 3 additions & 3 deletions compiler/src/model/build-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,14 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
const queryType = type.query.find(property => property != null && property.name === part.name) as model.Property
if (!deepEqual(queryType.type, part.type)) {
assert(pathMember as Node, part.codegenName != null, `'${part.name}' already exist in the query_parameters with a different type, you should define an @codegen_name.`)
assert(pathMember as Node, !type.query.map(p => p.name).includes(part.codegenName), `The codegen_name '${part.codegenName}' already exists as parameter in query_parameters.`)
assert(pathMember as Node, !type.query.map(p => p.codegenName ?? p.name).includes(part.codegenName), `The codegen_name '${part.codegenName}' already exists as parameter in query_parameters.`)
}
}
if (bodyProperties.map(p => p.name).includes(part.name)) {
const bodyType = bodyProperties.find(property => property != null && property.name === part.name) as model.Property
if (!deepEqual(bodyType.type, part.type)) {
assert(pathMember as Node, part.codegenName != null, `'${part.name}' already exist in the body with a different type, you should define an @codegen_name.`)
assert(pathMember as Node, !bodyProperties.map(p => p.name).includes(part.codegenName), `The codegen_name '${part.codegenName}' already exists as parameter in body.`)
assert(pathMember as Node, !bodyProperties.map(p => p.codegenName ?? p.name).includes(part.codegenName), `The codegen_name '${part.codegenName}' already exists as parameter in body.`)
}
}
}
Expand All @@ -293,7 +293,7 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
)
assert(
(bodyMember as PropertySignature).getJsDocs(),
!type.path.map(p => p.name).concat(type.query.map(p => p.name)).includes(tags.codegen_name),
!type.path.map(p => p.codegenName ?? p.name).concat(type.query.map(p => p.codegenName ?? p.name)).includes(tags.codegen_name),
`The codegen_name '${tags.codegen_name}' already exists as a property in the path or query.`
)
type.body = {
Expand Down
Loading

0 comments on commit a66fc61

Please sign in to comment.