Skip to content

Commit 2eadedf

Browse files
authored
Merge branch 'main' into endpoints-not-models
2 parents a71b155 + 0bdc82a commit 2eadedf

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

compiler/src/model/build-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
400400
)
401401
const jsDocs = child.getJsDocs()
402402
if (jsDocs.length > 0) {
403-
exception.description = jsDocs[0].getDescription()
403+
exception.description = jsDocs[0].getDescription().replace(/\r/g, '')
404404
}
405405
if (child.getName() === 'statusCodes') {
406406
const value = child.getTypeNode()

compiler/src/model/utils.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ export function hoistRequestAnnotations (
589589

590590
if (jsDocs.length === 1) {
591591
const description = jsDocs[0].getDescription()
592-
if (description.length > 0) request.description = description.trim()
592+
if (description.length > 0) request.description = description.trim().replace(/\r/g, '')
593593
}
594594
const tags = parseJsDocTags(jsDocs)
595595
const apiName = tags.rest_spec_name
@@ -639,7 +639,7 @@ export function hoistRequestAnnotations (
639639
endpoint.docId = value.trim()
640640
const docUrl = docIds.find(entry => entry[0] === value.trim())
641641
assert(jsDocs, docUrl != null, `The @doc_id '${value.trim()}' is not present in _doc_ids/table.csv`)
642-
endpoint.docUrl = docUrl[1]
642+
endpoint.docUrl = docUrl[1].replace(/\r/g, '')
643643
} else if (tag === 'availability') {
644644
// The @availability jsTag is different than most because it allows
645645
// multiple values within the same docstring, hence needing to parse
@@ -685,7 +685,7 @@ export function hoistTypeAnnotations (type: model.TypeDefinition, jsDocs: JSDoc[
685685
const tags = parseJsDocTags(jsDocs)
686686
if (jsDocs.length === 1) {
687687
const description = jsDocs[0].getDescription()
688-
if (description.length > 0) type.description = description.trim()
688+
if (description.length > 0) type.description = description.trim().replace(/\r/g, '')
689689
}
690690

691691
setTags(jsDocs, type, tags, validTags, (tags, tag, value) => {
@@ -703,13 +703,13 @@ export function hoistTypeAnnotations (type: model.TypeDefinition, jsDocs: JSDoc[
703703
assert(jsDocs, typeof tags.variants === 'string', '@non_exhaustive only applies to enums and @variants')
704704
} else if (tag === 'doc_url') {
705705
assert(jsDocs, isValidUrl(value), '@doc_url is not a valid url')
706-
type.docUrl = value
706+
type.docUrl = value.replace(/\r/g, '')
707707
} else if (tag === 'doc_id') {
708708
assert(jsDocs, value.trim() !== '', `Type ${type.name.namespace}.${type.name.name}'s @doc_id cannot be empty`)
709709
type.docId = value.trim()
710710
const docUrl = docIds.find(entry => entry[0] === value.trim())
711711
assert(jsDocs, docUrl != null, `The @doc_id '${value.trim()}' is not present in _doc_ids/table.csv`)
712-
type.docUrl = docUrl[1]
712+
type.docUrl = docUrl[1].replace(/\r/g, '')
713713
} else if (tag === 'codegen_names') {
714714
type.codegenNames = parseCommaSeparated(value)
715715
assert(jsDocs,
@@ -736,7 +736,7 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
736736
const tags = parseJsDocTags(jsDocs)
737737
if (jsDocs.length === 1) {
738738
const description = jsDocs[0].getDescription()
739-
if (description.length > 0) property.description = description.trim()
739+
if (description.length > 0) property.description = description.trim().replace(/\r/g, '')
740740
}
741741

742742
if (tags.doc_id != null) {
@@ -755,7 +755,7 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
755755
property.codegenName = value
756756
} else if (tag === 'doc_url') {
757757
assert(jsDocs, isValidUrl(value), '@doc_url is not a valid url')
758-
property.docUrl = value
758+
property.docUrl = value.replace(/\r/g, '')
759759
} else if (tag === 'availability') {
760760
// The @availability jsTag is different than most because it allows
761761
// multiple values within the same docstring, hence needing to parse
@@ -784,7 +784,7 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
784784
property.docId = value
785785
const docUrl = docIds.find(entry => entry[0] === value)
786786
if (docUrl != null) {
787-
property.docUrl = docUrl[1]
787+
property.docUrl = docUrl[1].replace(/\r/g, '')
788788
}
789789
} else if (tag === 'server_default') {
790790
assert(jsDocs, property.type.kind === 'instance_of' || property.type.kind === 'union_of' || property.type.kind === 'array_of', `Default values can only be configured for instance_of or union_of types, you are using ${property.type.kind}`)
@@ -859,7 +859,7 @@ function hoistEnumMemberAnnotations (member: model.EnumMember, jsDocs: JSDoc[]):
859859
const tags = parseJsDocTags(jsDocs)
860860
if (jsDocs.length === 1) {
861861
const description = jsDocs[0].getDescription()
862-
if (description.length > 0) member.description = description.trim()
862+
if (description.length > 0) member.description = description.trim().replace(/\r/g, '')
863863
}
864864

865865
setTags(jsDocs, member, tags, validTags, (tags, tag, value) => {
@@ -1298,7 +1298,7 @@ export function verifyUniqueness (project: Project): void {
12981298
if (path.startsWith('_types')) continue
12991299
if (!path.includes('_types')) continue
13001300

1301-
const namespace = path.startsWith('_global') ? `_global${sep}${path.split(sep)[1]}` : path.split(sep)[0]
1301+
const namespace = path.startsWith('_global') ? `_global${'/'}${path.split('/')[1]}` : path.split('/')[0]
13021302
const names = types.get(namespace) ?? []
13031303

13041304
for (const declaration of sourceFile.getClasses()) {
@@ -1339,7 +1339,7 @@ export function verifyUniqueness (project: Project): void {
13391339
const path = dirname(sourceFile.getFilePath().replace(/.*[/\\]specification[/\\]?/, ''))
13401340
if (path.includes('_types')) continue
13411341

1342-
const namespace = path.startsWith('_global') ? `_global${sep}${path.split(sep)[1]}` : path.split(sep)[0]
1342+
const namespace = path.startsWith('_global') ? `_global${'/'}${path.split('/')[1]}` : path.split('/')[0]
13431343
const names = types.get(path) ?? []
13441344
const localTypes = types.get(namespace) ?? []
13451345

@@ -1407,7 +1407,7 @@ export function deepEqual (a: any, b: any): boolean {
14071407
}
14081408
}
14091409

1410-
const basePath = join(__dirname, '..', '..', '..', 'specification') + '/'
1410+
const basePath = (join(__dirname, '..', '..', '..', 'specification') + sep).replace(/\\/g, '/')
14111411

14121412
export function sourceLocation (node: Node): string {
14131413
const sourceFile = node.getSourceFile()

0 commit comments

Comments
 (0)