Skip to content

Commit

Permalink
feat(cli): Add support for object property 'access' field (#6197)
Browse files Browse the repository at this point in the history
  • Loading branch information
amckinney authored Feb 26, 2025
1 parent a7b0362 commit fa2e6a3
Show file tree
Hide file tree
Showing 91 changed files with 6,142 additions and 47 deletions.
30 changes: 22 additions & 8 deletions fern.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,19 @@
}
]
},
"types.TypeReferenceDeclarationWithName": {
"types.ObjectPropertyAccess": {
"type": "string",
"enum": [
"read-only",
"write-only"
]
},
"types.ObjectPropertyWithAccessSchema": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"default": {
"oneOf": [
{
Expand Down Expand Up @@ -439,28 +449,32 @@
}
]
},
"type": {
"type": "string"
"access": {
"oneOf": [
{
"$ref": "#/definitions/types.ObjectPropertyAccess"
},
{
"type": "null"
}
]
}
},
"required": [
"type"
],
"additionalProperties": false
},
"types.TypeReferenceDeclarationWithNameSchema": {
"types.ObjectPropertySchema": {
"anyOf": [
{
"type": "string"
},
{
"$ref": "#/definitions/types.TypeReferenceDeclarationWithName"
"$ref": "#/definitions/types.ObjectPropertyWithAccessSchema"
}
]
},
"types.ObjectPropertySchema": {
"$ref": "#/definitions/types.TypeReferenceDeclarationWithNameSchema"
},
"types.ObjectSchema": {
"type": "object",
"properties": {
Expand Down
19 changes: 18 additions & 1 deletion fern/apis/fern-definition/definition/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,24 @@ types:
properties: optional<map<string, ObjectPropertySchema>>
extra-properties: optional<boolean>

ObjectPropertySchema: TypeReferenceDeclarationWithNameSchema
ObjectPropertySchema:
discriminated: false
union:
- string
- ObjectPropertyWithAccessSchema

ObjectPropertyWithAccessSchema:
extends:
- TypeReferenceDeclarationWithName
properties:
access: optional<ObjectPropertyAccess>

ObjectPropertyAccess:
enum:
- value: read-only
name: ReadOnly
- value: write-only
name: WriteOnly

ObjectExtendsSchema:
discriminated: false
Expand Down
30 changes: 22 additions & 8 deletions package-yml.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,19 @@
}
]
},
"types.TypeReferenceDeclarationWithName": {
"types.ObjectPropertyAccess": {
"type": "string",
"enum": [
"read-only",
"write-only"
]
},
"types.ObjectPropertyWithAccessSchema": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"default": {
"oneOf": [
{
Expand Down Expand Up @@ -459,28 +469,32 @@
}
]
},
"type": {
"type": "string"
"access": {
"oneOf": [
{
"$ref": "#/definitions/types.ObjectPropertyAccess"
},
{
"type": "null"
}
]
}
},
"required": [
"type"
],
"additionalProperties": false
},
"types.TypeReferenceDeclarationWithNameSchema": {
"types.ObjectPropertySchema": {
"anyOf": [
{
"type": "string"
},
{
"$ref": "#/definitions/types.TypeReferenceDeclarationWithName"
"$ref": "#/definitions/types.ObjectPropertyWithAccessSchema"
}
]
},
"types.ObjectPropertySchema": {
"$ref": "#/definitions/types.TypeReferenceDeclarationWithNameSchema"
},
"types.ObjectSchema": {
"type": "object",
"properties": {
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
- changelogEntry:
- summary: The Fern definition now supports specifying object properties as `read-only` or `write-only`.
type: feat
irVersion: 55
version: 0.55.0

- changelogEntry:
- summary: Add support for the `x-fern-enum` extension in the AsyncAPI v3 parser.
type: feat
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"password": {
"type": "string"
}
},
"required": [
"id",
"name",
"email",
"password"
],
"additionalProperties": false,
"definitions": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export type ObjectPropertyAccess = "read-only" | "write-only";
export const ObjectPropertyAccess = {
ReadOnly: "read-only",
WriteOnly: "write-only",
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

import * as FernDefinition from "../../../index";

export type ObjectPropertySchema = FernDefinition.TypeReferenceDeclarationWithNameSchema;
export type ObjectPropertySchema = string | FernDefinition.ObjectPropertyWithAccessSchema;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as FernDefinition from "../../../index";

export interface ObjectPropertyWithAccessSchema extends FernDefinition.TypeReferenceDeclarationWithName {
"access"?: FernDefinition.ObjectPropertyAccess;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export * from "./BaseTypeDeclarationSchema";
export * from "./AliasSchema";
export * from "./ObjectSchema";
export * from "./ObjectPropertySchema";
export * from "./ObjectPropertyWithAccessSchema";
export * from "./ObjectPropertyAccess";
export * from "./ObjectExtendsSchema";
export * from "./EnumSchema";
export * from "./EnumValue";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as serializers from "../../../index";
import * as FernDefinition from "../../../../api/index";
import * as core from "../../../../core";

export const ObjectPropertyAccess: core.serialization.Schema<
serializers.ObjectPropertyAccess.Raw,
FernDefinition.ObjectPropertyAccess
> = core.serialization.enum_(["read-only", "write-only"]);

export declare namespace ObjectPropertyAccess {
export type Raw = "read-only" | "write-only";
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import * as serializers from "../../../index";
import * as FernDefinition from "../../../../api/index";
import * as core from "../../../../core";
import { TypeReferenceDeclarationWithNameSchema } from "./TypeReferenceDeclarationWithNameSchema";
import { ObjectPropertyWithAccessSchema } from "./ObjectPropertyWithAccessSchema";

export const ObjectPropertySchema: core.serialization.Schema<
serializers.ObjectPropertySchema.Raw,
FernDefinition.ObjectPropertySchema
> = TypeReferenceDeclarationWithNameSchema;
> = core.serialization.undiscriminatedUnion([core.serialization.string(), ObjectPropertyWithAccessSchema]);

export declare namespace ObjectPropertySchema {
export type Raw = TypeReferenceDeclarationWithNameSchema.Raw;
export type Raw = string | ObjectPropertyWithAccessSchema.Raw;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as serializers from "../../../index";
import * as FernDefinition from "../../../../api/index";
import * as core from "../../../../core";
import { ObjectPropertyAccess } from "./ObjectPropertyAccess";
import { TypeReferenceDeclarationWithName } from "./TypeReferenceDeclarationWithName";

export const ObjectPropertyWithAccessSchema: core.serialization.ObjectSchema<
serializers.ObjectPropertyWithAccessSchema.Raw,
FernDefinition.ObjectPropertyWithAccessSchema
> = core.serialization
.object({
"access": ObjectPropertyAccess.optional(),
})
.extend(TypeReferenceDeclarationWithName);

export declare namespace ObjectPropertyWithAccessSchema {
export interface Raw extends TypeReferenceDeclarationWithName.Raw {
"access"?: ObjectPropertyAccess.Raw | null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export * from "./BaseTypeDeclarationSchema";
export * from "./AliasSchema";
export * from "./ObjectSchema";
export * from "./ObjectPropertySchema";
export * from "./ObjectPropertyWithAccessSchema";
export * from "./ObjectPropertyAccess";
export * from "./ObjectExtendsSchema";
export * from "./EnumSchema";
export * from "./EnumValue";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export function visitTypeDeclaration({
audiences: noop,
encoding: noop,
default: noop,
validation: noop
validation: noop,
access: noop
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export function visitWebhooks({
audiences: noop,
encoding: noop,
default: noop,
validation: noop
validation: noop,
access: noop
});
}
}
Expand Down
Loading

0 comments on commit fa2e6a3

Please sign in to comment.