Skip to content

Stronger implementation of readonly and writeonly fields #6

@jhannes

Description

@jhannes

Motivating example with OmitReadOnly and OmitWriteOnly:

export interface PetsApiInterface {

    addPet(params: {
        pathParams: { storeId: string };
        petDto?: OmitReadOnly<PetDto>;
    }): Promise<void>;
   
    listPets(params: {
        pathParams: { storeId: string };
        queryParams?: { status?: Array<string>, tags?: Array<string>, bornAfter?: Date,  };
    }): Promise<OmitWriteOnly<PetDto>>;
}

OmitReadOnly can be created using https://stackoverflow.com/a/49579497/27658. Alternatively, OmitWriteOnly<PetDto> = Omit<PetDto, "foo" | "bar" | "baz"> can be generated (but the LHS syntax is probably to possible).

If this is done, the test data generator must also be updated to support Full, Input, Output (and perhaps MinimalOutput and MinimalInput) variants as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions