Giter Site home page Giter Site logo

Comments (9)

vladmiller avatar vladmiller commented on August 18, 2024 1

@mrlubos Yes

from openapi-ts.

mrlubos avatar mrlubos commented on August 18, 2024 1

@vladmiller this will be available in the next release 🤝

from openapi-ts.

vladmiller avatar vladmiller commented on August 18, 2024 1

@mrlubos thank you so much! I actually did not expect such a fast update!

from openapi-ts.

mrlubos avatar mrlubos commented on August 18, 2024 1

It doesn't modify the field for standalone clients, if you follow that code you should see where it's branching. Are you able to use a standalone client?

from openapi-ts.

vladmiller avatar vladmiller commented on August 18, 2024 1

@mrlubos I see, I did not realize that choice of the client will impact this.

This produces exactly what I wanted. Thanks again.

openapi-ts --input http://127.0.0.1:5000/swagger/swagger.json --output app/api --services false --exportCore false --client @hey-api/client-fetch

from openapi-ts.

mrlubos avatar mrlubos commented on August 18, 2024

Hey @vladmiller, is that the only config you have? Mind sharing also example output vs expected even for a single model?

from openapi-ts.

vladmiller avatar vladmiller commented on August 18, 2024

@mrlubos apologies for long text.

Here is the command. I do not use the config file.

pnpm openapi-ts --input ./api.yaml --output app/api --exportCore false --schemas false --services false

Version:

      '@hey-api/openapi-ts':
        specifier: ^0.47.0
        version: 0.47.0([email protected])

Here is a stripped down example of the API and below is generated types.gen.ts

components:
  schemas:
    HTTPProblem:
      properties:
        detail:
          description: A human-readable explanation specific to this occurrence of the problem.
          type: string
        instance:
          description: A URL that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
          format: url
          type: string
        title:
          description: A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
          type: string
        type:
          description: A URL that identifies the problem type. This MUST be an absolute URI.
          format: url
          type: string
      type: object
    MarshmallowValidationProblem:
      properties:
        detail:
          description: A human-readable explanation specific to this occurrence of the problem.
          type: string
        fields:
          description: A dictionary of field names that caused the error and the corresponding error messages.
          type: object
        instance:
          description: A URL that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
          format: url
          type: string
        location:
          description: A location of where the error occurred, e.g. 'query', 'body', 'path', etc.
          type: string
        title:
          description: A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
          type: string
        type:
          description: A URL that identifies the problem type. This MUST be an absolute URI.
          format: url
          type: string
      type: object
    PropertyV2:
      properties:
        active:
          description: Whether or not the building has available units and is otherwise available for showings.
          type: boolean
        address:
          description: The street address of the property
          type: string
        agent_self_assign_enabled:
          description: Indicates whether agent self-assign is available at this property
          type: boolean
        average_rent:
          description: The average rent of all units in the property.
          nullable: true
          type: number
        bedrooms:
          description: A sorted list of all available floorplan bedrooms in the property. Value provided only for active properties.
          items:
            type: integer
          nullable: true
          type: array
        city:
          description: The city where the property is located
          type: string
        commission_type:
          description: The type of commission for the property.
          enum:
            - percentage
            - flat
            - null
          nullable: true
          type: string
        commission_value:
          description: The commission value for the property.
          nullable: true
          type: number
        cover_media:
          description: A list of URLs of the cover images.
          items:
            format: url
            type: string
          type: array
        created_at:
          description: Date the property was added to the inventory.
          format: date-time
          type: string
        id:
          description: The unique identifier of the property
          type: integer
        is_assigned_to_agent:
          description: Indicates whether the current agent is assigned to the property.
          type: boolean
        is_new:
          description: Indicates whether the property is new.
          type: boolean
        is_verified:
          description: Indicates whether the property is verified.
          type: boolean
        latitude:
          description: The latitude of the property
          type: number
        longitude:
          description: The longitude of the property
          type: number
        marketing_title:
          description: The marketing title of the property
          type: string
        rents:
          description: The minimum and maximum rent of all rentable units in the property. Value provided only for active properties.
          items:
            type: number
          nullable: true
          type: array
        state:
          description: The state where the property is located
          type: string
        updated_at:
          description: Date the property was last updated.
          format: date-time
          type: string
        zip:
          description: The ZIP code of the property
          type: string
      required:
        - active
        - address
        - city
        - id
        - is_assigned_to_agent
        - is_new
        - is_verified
        - latitude
        - longitude
        - marketing_title
        - state
        - zip
      type: object

info:
  description: RESTful API for the agent applications
  title: restful-api
  version: 1.1.0
openapi: 3.0.3
paths:
  /api/v2/inventory/:
    get:
      parameters:
        - description: Used for the full-text search of properties by marketing_title,address, city, state or zip code
          in: query
          name: property_search
          required: false
          schema:
            nullable: true
            type: string
        - description: Filter properties by the geo boundary. Accepts a GeoJSON Polygon.
          in: query
          name: geo_boundary
          required: false
          schema:
            example: '{"coordinates": [[[-118.34302785013696, 34.13695548582709], [-118.34302785013696, 33.999153056651664], [-118.1321157150851, 33.999153056651664], [-118.1321157150851, 34.13695548582709], [-118.34302785013696, 34.13695548582709]]], "type": "Polygon"}'
            type: string
        - description: Filter properties by the number of bedrooms.
          explode: true
          in: query
          name: bedrooms
          required: false
          schema:
            items:
              enum:
                - '0'
                - '1'
                - '2'
                - '3'
                - 4+
              type: string
            type: array
          style: form
        - description: Filter properties by the number of bathrooms.
          explode: true
          in: query
          name: bathrooms
          required: false
          schema:
            items:
              enum:
                - '1'
                - '2'
                - '3'
                - 4+
              type: string
            type: array
          style: form
        - description: Filter properties by the available unit prices.
          in: query
          name: min_price
          required: false
          schema:
            maximum: 25000
            minimum: 1000
            type: number
        - description: Filter properties by the available unit prices.
          in: query
          name: max_price
          required: false
          schema:
            maximum: 25000
            minimum: 1000
            type: number
        - description: Filter by units size.
          in: query
          name: min_sqft
          required: false
          schema:
            maximum: 20000
            minimum: 0
            type: number
        - description: Filter by units size.
          in: query
          name: max_sqft
          required: false
          schema:
            maximum: 20000
            minimum: 0
            type: number
        - description: Will only work if set to True. Other values are ignored.
          in: query
          name: cats_allowed
          required: false
          schema:
            type: boolean
        - description: Will only work if set to True. Other values are ignored.
          in: query
          name: small_dogs_allowed
          required: false
          schema:
            type: boolean
        - description: Will only work if set to True. Other values are ignored.
          in: query
          name: large_dogs_allowed
          required: false
          schema:
            type: boolean
        - description: Will only work if set to True. Other values are ignored.
          in: query
          name: has_parking
          required: false
          schema:
            type: boolean
        - description: Filter by property year built.
          in: query
          name: min_year_built
          required: false
          schema:
            maximum: 2100
            minimum: 1900
            type: number
        - description: Filter by property year built.
          in: query
          name: max_year_built
          required: false
          schema:
            maximum: 2100
            minimum: 1900
            type: number
        - description: Whether to include inactive properties in the result.
          in: query
          name: include_inactive
          required: false
          schema:
            type: boolean
        - description: Filter by property amenities.
          explode: true
          in: query
          name: property_amenities
          required: false
          schema:
            items:
              enum:
                - Security System
                - Business Center
                - Rooftop
                - Fitness Center
                - Pool
                - Sauna
              type: string
            type: array
          style: form
        - in: query
          name: order_by
          required: false
          schema:
            enum:
              - price-asc
              - price-desc
              - recently-updated
              - avg-commission-desc
              - recommended
            type: string
        - description: Show properties where agent is assigned
          in: query
          name: is_assigned
          required: false
          schema:
            type: boolean
        - description: The ID of the list that the agent is viewing. If provided, the query will be filtered to only include properties that are in the list.
          in: query
          name: by_list_id
          required: false
          schema:
            type: integer
        - description: How many items to return after filters are applied.
          in: query
          name: limit
          required: false
          schema:
            maximum: 250
            minimum: 1
            type: integer
        - description: How many items to skip before returning the rest.
          in: query
          name: offset
          required: false
          schema:
            minimum: 0
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/PropertyV2'
                type: array
          description: A collection of properties.
          headers:
            X-Geo-Count:
              description: The number of properties available after all filters applied, including Geo filters.
              schema:
                type: integer
            X-Total-Count:
              description: The total number of properties available after filters applied, but without Geo filters.
              schema:
                type: integer
        '422':
          content:
            application/json+problem:
              schema:
                $ref: '#/components/schemas/MarshmallowValidationProblem'
          description: Schema validation failed
        '500':
          content:
            application/json+problem:
              schema:
                $ref: '#/components/schemas/HTTPProblem'
          description: Internal server error

      summary: Return a collection of available properties.
      tags:
        - inventory
// This file is auto-generated by @hey-api/openapi-ts

export type HTTPProblem = {
    /**
     * A human-readable explanation specific to this occurrence of the problem.
     */
    detail?: string;
    /**
     * A URL that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
     */
    instance?: string;
    /**
     * A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
     */
    title?: string;
    /**
     * A URL that identifies the problem type. This MUST be an absolute URI.
     */
    type?: string;
};

export type MarshmallowValidationProblem = {
    /**
     * A human-readable explanation specific to this occurrence of the problem.
     */
    detail?: string;
    /**
     * A dictionary of field names that caused the error and the corresponding error messages.
     */
    fields?: {
        [key: string]: unknown;
    };
    /**
     * A URL that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
     */
    instance?: string;
    /**
     * A location of where the error occurred, e.g. 'query', 'body', 'path', etc.
     */
    location?: string;
    /**
     * A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
     */
    title?: string;
    /**
     * A URL that identifies the problem type. This MUST be an absolute URI.
     */
    type?: string;
};

export type PropertyV2 = {
    /**
     * Whether or not the building has available units and is otherwise available for showings.
     */
    active: boolean;
    /**
     * The street address of the property
     */
    address: string;
    /**
     * Indicates whether agent self-assign is available at this property
     */
    agent_self_assign_enabled?: boolean;
    /**
     * The average rent of all units in the property.
     */
    average_rent?: number | null;
    /**
     * A sorted list of all available floorplan bedrooms in the property. Value provided only for active properties.
     */
    bedrooms?: Array<(number)> | null;
    /**
     * The city where the property is located
     */
    city: string;
    /**
     * The type of commission for the property.
     */
    commission_type?: 'percentage' | 'flat' | null;
    /**
     * The commission value for the property.
     */
    commission_value?: number | null;
    /**
     * A list of URLs of the cover images.
     */
    cover_media?: Array<(string)>;
    /**
     * Date the property was added to the inventory.
     */
    created_at?: string;
    /**
     * The unique identifier of the property
     */
    id: number;
    /**
     * Indicates whether the current agent is assigned to the property.
     */
    is_assigned_to_agent: boolean;
    /**
     * Indicates whether the property is new.
     */
    is_new: boolean;
    /**
     * Indicates whether the property is verified.
     */
    is_verified: boolean;
    /**
     * The latitude of the property
     */
    latitude: number;
    /**
     * The longitude of the property
     */
    longitude: number;
    /**
     * The marketing title of the property
     */
    marketing_title: string;
    /**
     * The minimum and maximum rent of all rentable units in the property. Value provided only for active properties.
     */
    rents?: Array<(number)> | null;
    /**
     * The state where the property is located
     */
    state: string;
    /**
     * Date the property was last updated.
     */
    updated_at?: string;
    /**
     * The ZIP code of the property
     */
    zip: string;
};

/**
 * The type of commission for the property.
 */
export type commission_type = 'percentage' | 'flat';

When services are enabled, here is the types.gen.ts

// Same as above + the following

export type GetApiV2InventoryData = {
    /**
     * Filter properties by the number of bathrooms.
     */
    bathrooms?: Array<('1' | '2' | '3' | '4+')>;
    /**
     * Filter properties by the number of bedrooms.
     */
    bedrooms?: Array<('0' | '1' | '2' | '3' | '4+')>;
    /**
     * The ID of the list that the agent is viewing. If provided, the query will be filtered to only include properties that are in the list.
     */
    byListId?: number;
    /**
     * Will only work if set to True. Other values are ignored.
     */
    catsAllowed?: boolean;
    /**
     * Filter properties by the geo boundary. Accepts a GeoJSON Polygon.
     */
    geoBoundary?: string;
    /**
     * Will only work if set to True. Other values are ignored.
     */
    hasParking?: boolean;
    /**
     * Whether to include inactive properties in the result.
     */
    includeInactive?: boolean;
    /**
     * Show properties where agent is assigned
     */
    isAssigned?: boolean;
    /**
     * Will only work if set to True. Other values are ignored.
     */
    largeDogsAllowed?: boolean;
    /**
     * How many items to return after filters are applied.
     */
    limit?: number;
    /**
     * Filter properties by the available unit prices.
     */
    maxPrice?: number;
    /**
     * Filter by units size.
     */
    maxSqft?: number;
    /**
     * Filter by property year built.
     */
    maxYearBuilt?: number;
    /**
     * Filter properties by the available unit prices.
     */
    minPrice?: number;
    /**
     * Filter by units size.
     */
    minSqft?: number;
    /**
     * Filter by property year built.
     */
    minYearBuilt?: number;
    /**
     * How many items to skip before returning the rest.
     */
    offset?: number;
    orderBy?: 'price-asc' | 'price-desc' | 'recently-updated' | 'avg-commission-desc' | 'recommended';
    /**
     * Filter by property amenities.
     */
    propertyAmenities?: Array<('Security System' | 'Business Center' | 'Rooftop' | 'Fitness Center' | 'Pool' | 'Sauna')>;
    /**
     * Used for the full-text search of properties by marketing_title,address, city, state or zip code
     */
    propertySearch?: string | null;
    /**
     * Will only work if set to True. Other values are ignored.
     */
    smallDogsAllowed?: boolean;
};

export type GetApiV2InventoryResponse = Array<PropertyV2>;

export type $OpenApiTs = {
    '/api/v2/inventory/': {
        get: {
            req: GetApiV2InventoryData;
            res: {
                /**
                 * A collection of properties.
                 */
                200: Array<PropertyV2>;
                /**
                 * Schema validation failed
                 */
                422: MarshmallowValidationProblem;
                /**
                 * Internal server error
                 */
                500: HTTPProblem;
            };
        };
    };
};

from openapi-ts.

mrlubos avatar mrlubos commented on August 18, 2024

Thank you. And you're looking to generate all three GetApiV2InventoryData, GetApiV2InventoryResponse, and $OpenApiTs?

from openapi-ts.

vladmiller avatar vladmiller commented on August 18, 2024

Hey @mrlubos, it still converts fields to camelCase. If you can point me to the place where it's generated I can figure out the rest and submit a PR.

export type GetApiV2InventoryData = {
    // ... skipped
    byListId?: number;
    /**
     * Will only work if set to True. Other values are ignored.
     */
    catsAllowed?: boolean;
    // ... skipped
};

from openapi-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.