Skip to content

support for x-nullable (and other x- props) #77

@atlefren

Description

@atlefren

This library works great, but the swagger endpoints i'm using it against use the x-nullable property to indicate optional parameters (why it's doing that is another issue, don't ask).

I think it's easier to change the code generation than it is changing a lot of swagger defs, so I would really appreciate if this library had an option to support various x-flags.

What I'm thinking is an option to provide a mapper to the generator, something along the lines of


interface SwaggerProps {
 [string]: any //not sure how "unknown" props should be typed
}

interface Parameter {
  name: string;
  type: Type;
  required: boolean;
  //etc...
}


const mapper = (swaggerProps: SwaggerProps, parameter: Parameter): Parameter => {
    return {...parameter, required: !swaggerProps['x-nullable']};
}

swaggerToTS(cleanedSwaggerDefinition, {wrapper: false, mapper: mapper})

Does this sound like something you would consider including? I could try to implement it and submit a PR, but I would like a discussion up front in order to know it's something that will be considered for inclusion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions