Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@typespec/openapi3

Package Overview
Dependencies
Maintainers
2
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typespec/openapi3 - npm Package Compare versions

Comparing version 0.57.0-dev.0 to 0.57.0-dev.1

6

dist/src/openapi.js

@@ -220,3 +220,3 @@ import { compilerAssert, createDiagnosticCollector, emitFile, getAllTags, getAnyExtensionFromPath, getDoc, getEncode, getFormat, getKnownValues, getMaxItems, getMaxLength, getMaxValue, getMaxValueExclusive, getMinItems, getMinLength, getMinValue, getMinValueExclusive, getNamespaceFullName, getPattern, getService, getSummary, ignoreDiagnostics, interpolatePath, isDeprecated, isGlobalNamespace, isNeverType, isSecret, isVoidType, listServices, navigateTypesInNamespace, projectProgram, resolvePath, } from "@typespec/compiler";

const variable = {
default: prop.default ? getDefaultValue(program, prop.type, prop.default) : "",
default: prop.defaultValue ? getDefaultValue(program, prop.defaultValue) : "",
description: getDoc(program, prop),

@@ -976,4 +976,4 @@ };

const schema = applyEncoding(param, applyIntrinsicDecorators(param, typeSchema));
if (param.default) {
schema.default = getDefaultValue(program, param.type, param.default);
if (param.defaultValue) {
schema.default = getDefaultValue(program, param.defaultValue);
}

@@ -980,0 +980,0 @@ // Description is already provided in the parameter itself.

@@ -1,2 +0,2 @@

import { BooleanLiteral, Enum, EnumMember, IntrinsicType, Model, ModelProperty, NumericLiteral, Program, Scalar, StringLiteral, StringTemplate, Tuple, Type, Union, UnionVariant } from "@typespec/compiler";
import { BooleanLiteral, Enum, EnumMember, IntrinsicType, Model, ModelProperty, NumericLiteral, Program, Scalar, StringLiteral, StringTemplate, Tuple, Type, Union, UnionVariant, Value } from "@typespec/compiler";
import { AssetEmitter, Context, Declaration, EmitEntity, EmitterOutput, ReferenceCycle, Scope, TypeEmitter } from "@typespec/compiler/emitter-framework";

@@ -49,3 +49,3 @@ import { MetadataInfo } from "@typespec/http";

}
export declare function getDefaultValue(program: Program, type: Type, defaultType: Type): any;
export declare function getDefaultValue(program: Program, defaultType: Value): any;
//# sourceMappingURL=schema-emitter.d.ts.map

@@ -1,2 +0,2 @@

import { compilerAssert, getDeprecated, getDiscriminatedUnion, getDiscriminator, getDoc, getEncode, getFormat, getKnownValues, getMaxItems, getMaxLength, getMaxValue, getMaxValueExclusive, getMinItems, getMinLength, getMinValue, getMinValueExclusive, getNamespaceFullName, getPattern, getSummary, getTypeName, ignoreDiagnostics, isArrayModelType, isNeverType, isNullType, isSecret, isTemplateDeclaration, resolveEncodedName, stringTemplateToString, } from "@typespec/compiler";
import { compilerAssert, explainStringTemplateNotSerializable, getDeprecated, getDiscriminatedUnion, getDiscriminator, getDoc, getEncode, getFormat, getKnownValues, getMaxItems, getMaxLength, getMaxValue, getMaxValueExclusive, getMinItems, getMinLength, getMinValue, getMinValueExclusive, getNamespaceFullName, getPattern, getSummary, getTypeName, ignoreDiagnostics, isArrayModelType, isNeverType, isNullType, isSecret, isTemplateDeclaration, resolveEncodedName, } from "@typespec/compiler";
import { ArrayBuilder, ObjectBuilder, Placeholder, TypeEmitter, } from "@typespec/compiler/emitter-framework";

@@ -224,4 +224,4 @@ import { Visibility, getVisibilitySuffix } from "@typespec/http";

const additionalProps = this.#applyConstraints(prop, {});
if (prop.default) {
additionalProps.default = getDefaultValue(program, prop.type, prop.default);
if (prop.defaultValue) {
additionalProps.default = getDefaultValue(program, prop.defaultValue);
}

@@ -263,10 +263,10 @@ if (isReadonlyProperty(program, prop)) {

stringTemplate(string) {
const [value, diagnostics] = stringTemplateToString(string);
if (diagnostics.length > 0) {
this.emitter
.getProgram()
.reportDiagnostics(diagnostics.map((x) => ({ ...x, severity: "warning" })));
return { type: "string" };
if (string.stringValue !== undefined) {
return { type: "string", enum: [string.stringValue] };
}
return { type: "string", enum: [value] };
const diagnostics = explainStringTemplateNotSerializable(string);
this.emitter
.getProgram()
.reportDiagnostics(diagnostics.map((x) => ({ ...x, severity: "warning" })));
return { type: "string" };
}

@@ -744,34 +744,20 @@ numericLiteral(number) {

};
export function getDefaultValue(program, type, defaultType) {
switch (defaultType.kind) {
case "String":
export function getDefaultValue(program, defaultType) {
switch (defaultType.valueKind) {
case "StringValue":
return defaultType.value;
case "Number":
case "NumericValue":
return defaultType.value.asNumber() ?? undefined;
case "BooleanValue":
return defaultType.value;
case "Boolean":
return defaultType.value;
case "Tuple":
compilerAssert(type.kind === "Tuple" || (type.kind === "Model" && isArrayModelType(program, type)), "setting tuple default to non-tuple value");
if (type.kind === "Tuple") {
return defaultType.values.map((defaultTupleValue, index) => getDefaultValue(program, type.values[index], defaultTupleValue));
}
else {
return defaultType.values.map((defaultTuplevalue) => getDefaultValue(program, type.indexer.value, defaultTuplevalue));
}
case "Intrinsic":
return isNullType(defaultType)
? null
: reportDiagnostic(program, {
code: "invalid-default",
format: { type: defaultType.kind },
target: defaultType,
});
case "EnumMember":
return defaultType.value ?? defaultType.name;
case "UnionVariant":
return getDefaultValue(program, type, defaultType.type);
case "ArrayValue":
return defaultType.values.map((x) => getDefaultValue(program, x));
case "NullValue":
return null;
case "EnumValue":
return defaultType.value.value ?? defaultType.value.name;
default:
reportDiagnostic(program, {
code: "invalid-default",
format: { type: defaultType.kind },
format: { type: defaultType.valueKind },
target: defaultType,

@@ -778,0 +764,0 @@ });

{
"name": "@typespec/openapi3",
"version": "0.57.0-dev.0",
"version": "0.57.0-dev.1",
"author": "Microsoft Corporation",

@@ -5,0 +5,0 @@ "description": "TypeSpec library for emitting OpenAPI 3.0 from the TypeSpec REST protocol binding",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc