Skip to content

dateType โ€‹

Type: string | Required

Specifies how to handle date/datetime fields in the generated code.

Usage โ€‹

typescript
// openapi.config.ts
import { GeneratorConfig } from 'ng-openapi';

const config: GeneratorConfig = {
  options: {
    dateType: 'Date' // or 'string'
  },
  ... // other configurations
};

export default config;

Supported Options โ€‹

'Date' (Default) โ€‹

Generates date objects with automatic transformation for date and datetime fields.

typescript
interface Event {
    id: number;
    name: string;
    date: Date; // Automatically transformed to Date object
}

'string' โ€‹

Generates string types for date and datetime fields without any transformation.

typescript
interface Event {
    id: number;
    name: string;
    date: string; // No transformation, just a string
}

Notes โ€‹

  • Using 'Date' generates an HTTP Interceptor that automatically transforms date strings to Date objects
  • The interceptor is included by default unless disabled in the provider configuration

Released under the MIT License.
This site is powered by Netlify
About ยท Impressum