OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
22.03k stars 6.6k forks source link

Rust: Stripe open api spec v3 does not compile #7975

Open broccolihighkicks opened 4 years ago

broccolihighkicks commented 4 years ago

Hello,

The Stripe open api v3 spec does not compile with Rust code gen:

Steps to reproduce:

cargo build errors:

error[E0428]: the name `EtcGMT0` is defined multiple times
error[E0428]: the name `EtcGMT1` is defined multiple times
error[E0428]: the name `EtcGMT10` is defined multiple times
error[E0428]: the name `EtcGMT11` is defined multiple times
error[E0428]: the name `EtcGMT12` is defined multiple times
error[E0428]: the name `EtcGMT2` is defined multiple times
error[E0428]: the name `EtcGMT3` is defined multiple times
error[E0428]: the name `EtcGMT4` is defined multiple times
error[E0428]: the name `EtcGMT5` is defined multiple times
error[E0428]: the name `EtcGMT6` is defined multiple times
error[E0428]: the name `EtcGMT7` is defined multiple times
error[E0428]: the name `EtcGMT8` is defined multiple times
error[E0428]: the name `EtcGMT9` is defined multiple times
error[E0428]: the name `GMT0` is defined multiple times
error[E0433]: failed to resolve: `crate` in paths can only be used in start position
error[E0433]: failed to resolve: could not find `serde_json` in `models`
error[E0412]: cannot find type `AnyOfpaymentSourcedeletedPaymentSource` in module `crate::models`
error[E0412]: cannot find type `AnyOfcustomerdeletedCustomer` in module `crate::models`
error[E0412]: cannot find type `AnyOfrecipientdeletedRecipient` in module `crate::models`
error[E0412]: cannot find type `AnyOfskudeletedSku` in module `crate::models`
error[E0412]: cannot find type `AnyOfcardbankAccountsource` in module `crate::models`
error[E0412]: cannot find type `AnyOfaccountBusinessProfile` in module `crate::models`
error[E0412]: cannot find type `AnyOfaccountSettings` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringfile` in module `crate::models`
error[E0412]: cannot find type `AnyOfaddress` in module `crate::models`
error[E0412]: cannot find type `AnyOfarraystring` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringcustomerdeletedCustomer` in module `crate::models`
error[E0412]: cannot find type `AnyOfbankAccountcardsource` in module `crate::models`
error[E0412]: cannot find type `AnyOfalipayAccountbankAccountbitcoinReceivercardsource` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringaccount` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringapplication` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringbalanceTransaction` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringcharge` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringapplicationFeechargeconnectCollectionTransferdisputefeeRefundissuingAuthorizationissuingDisputeissuingTransactionpayoutplatformTaxFeerefundreserveTransactiontaxDeductedAtSourcetopuptransfertransferReversal` in module `crate::models`
error[E0412]: cannot find type `AnyOfobjectstring` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringrecipient` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringapplicationFee` in module `crate::models`
error[E0412]: cannot find type `AnyOfchargeFraudDetails` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringinvoice` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringorder` in module `crate::models`
error[E0412]: cannot find type `AnyOfchargeOutcome` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringpaymentIntent` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodDetails` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringreview` in module `crate::models`
error[E0412]: cannot find type `AnyOfshipping` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringtransfer` in module `crate::models`
error[E0412]: cannot find type `AnyOfchargeTransferData` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringrule` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringsetupIntent` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentPagesPaymentPageResourcesShippingAddressCollection` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringsubscription` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentPagesCheckoutSessionTotalDetails` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringcustomerBalanceTransaction` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringrefund` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringtaxRate` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringalipayAccountbankAccountbitcoinReceivercardsource` in module `crate::models`
error[E0412]: cannot find type `AnyOfdiscount` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringcreditNote` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringcustomer` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringpromotionCode` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringdiscountdeletedDiscount` in module `crate::models`
error[E0412]: cannot find type `AnyOfnotificationEventRequest` in module `crate::models`
error[E0412]: cannot find type `AnyOfbankAccountcard` in module `crate::models`
error[E0412]: cannot find type `AnyOfmapstring` in module `crate::models`
error[E0412]: cannot find type `AnyOfintegerstring` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringstring` in module `crate::models`
error[E0412]: cannot find type `AnyOfobjectobject` in module `crate::models`
error[E0412]: cannot find type `AnyOfbooleanstring` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringinteger` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringintegerstring` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringpaymentMethod` in module `crate::models`
error[E0412]: cannot find type `AnyOfapiErrors` in module `crate::models`
error[E0412]: cannot find type `AnyOfinvoiceTransferData` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringdiscount` in module `crate::models`
error[E0412]: cannot find type `AnyOfprice` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingAuthorizationAmountDetails` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringissuingCardholder` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingAuthorizationPendingRequest` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringissuingCard` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingCardShipping` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingCardholderCompany` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingCardholderIndividual` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingCardholderAuthorizationControls` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingCardholderIndividualDob` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingCardholderVerification` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingCardholderIdDocument` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringissuingTransaction` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingTransactionAmountDetails` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringissuingAuthorization` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringissuingDispute` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingTransactionPurchaseDetails` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingTransactionFlightData` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingTransactionFuelData` in module `crate::models`
error[E0412]: cannot find type `AnyOfissuingTransactionLodgingData` in module `crate::models`
error[E0412]: cannot find type `AnyOflegalEntityJapanAddress` in module `crate::models`
error[E0412]: cannot find type `AnyOflegalEntityCompanyVerification` in module `crate::models`
error[E0412]: cannot find type `AnyOflegalEntityPersonVerificationDocument` in module `crate::models`
error[E0412]: cannot find type `AnyOfstatusTransitions` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringsku` in module `crate::models`
error[E0412]: cannot find type `AnyOfobjectinteger` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentIntentNextAction` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentIntentPaymentMethodOptions` in module `crate::models`
error[E0412]: cannot find type `AnyOftransferData` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodOptionsCardInstallments` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodCardChecks` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodCardGeneratedCard` in module `crate::models`
error[E0412]: cannot find type `AnyOfnetworks` in module `crate::models`
error[E0412]: cannot find type `AnyOfthreeDSecureUsage` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodCardWallet` in module `crate::models`
error[E0412]: cannot find type `AnyOfcardGeneratedFromPaymentMethodDetails` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringmandate` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodDetailsCardChecks` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodDetailsCardInstallments` in module `crate::models`
error[E0412]: cannot find type `AnyOfthreeDSecureDetails` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodDetailsCardWallet` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodDetailsCardInstallmentsPlan` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodDetailsCardPresentReceipt` in module `crate::models`
error[E0412]: cannot find type `AnyOfpaymentMethodDetailsInteracPresentReceipt` in module `crate::models`
error[E0412]: cannot find type `AnyOfsepaDebitGeneratedFrom` in module `crate::models`
error[E0412]: cannot find type `AnyOfsourceOwner` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringbankAccountcarddeletedBankAccountdeletedCard` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringpayout` in module `crate::models`
error[E0412]: cannot find type `AnyOfpersonRequirements` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringproductdeletedProduct` in module `crate::models`
error[E0412]: cannot find type `AnyOftransformUsage` in module `crate::models`
error[E0412]: cannot find type `AnyOfrecurring` in module `crate::models`
error[E0412]: cannot find type `AnyOftransformQuantity` in module `crate::models`
error[E0412]: cannot find type `AnyOfpackageDimensions` in module `crate::models`
error[E0412]: cannot find type `AnyOfbankAccount` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringcard` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringtransferReversal` in module `crate::models`
error[E0412]: cannot find type `AnyOfnumberstring` in module `crate::models`
error[E0412]: cannot find type `AnyOffile` in module `crate::models`
error[E0412]: cannot find type `AnyOfradarReviewResourceLocation` in module `crate::models`
error[E0412]: cannot find type `AnyOfradarReviewResourceSession` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringsetupAttempt` in module `crate::models`
error[E0412]: cannot find type `AnyOfsetupIntentNextAction` in module `crate::models`
error[E0412]: cannot find type `AnyOfsetupIntentPaymentMethodOptions` in module `crate::models`
error[E0412]: cannot find type `AnyOfdeliveryEstimate` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringproduct` in module `crate::models`
error[E0412]: cannot find type `AnyOfsubscriptionBillingThresholds` in module `crate::models`
error[E0412]: cannot find type `AnyOfsubscriptionsResourcePauseCollection` in module `crate::models`
error[E0412]: cannot find type `AnyOfsubscriptionPendingInvoiceItemInterval` in module `crate::models`
error[E0412]: cannot find type `AnyOfsubscriptionsResourcePendingUpdate` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringsubscriptionSchedule` in module `crate::models`
error[E0412]: cannot find type `AnyOfsubscriptionTransferData` in module `crate::models`
error[E0412]: cannot find type `AnyOfsubscriptionItemBillingThresholds` in module `crate::models`
error[E0412]: cannot find type `AnyOfsubscriptionScheduleCurrentPhase` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringpricedeletedPrice` in module `crate::models`
error[E0412]: cannot find type `AnyOfstringcoupondeletedCoupon` in module `crate::models`
error[E0412]: cannot find type `AnyOfinvoiceSettingSubscriptionScheduleSetting` in module `crate::models`
error[E0412]: cannot find type `AnyOftaxIdVerification` in module `crate::models`
error[E0599]: no method named `join` found for reference `&str` in the current scope
error[E0599]: no method named `to_string` found for reference `&models::all_people_relationship_specs::AllPeopleRelationshipSpecs` in the current scope
error[E0599]: no method named `to_string` found for reference `&models::all_people_relationship_specs_1::AllPeopleRelationshipSpecs1` in the current scope
error[E0599]: no method named `to_string` found for reference `&models::all_people_relationship_specs_2::AllPeopleRelationshipSpecs2` in the current scope
error[E0599]: no method named `to_string` found for reference `&models::all_people_relationship_specs_3::AllPeopleRelationshipSpecs3` in the current scope
error[E0599]: no method named `join` found for reference `&std::vec::Vec<models::credit_note_line_item_params::CreditNoteLineItemParams>` in the current scope
error[E0599]: no method named `to_string` found for reference `&std::collections::HashMap<std::string::String, std::string::String>` in the current scope
error[E0599]: no method named `join` found for reference `&std::vec::Vec<models::invoice_item_preview_params::InvoiceItemPreviewParams>` in the current scope
error[E0599]: no method named `join` found for reference `&std::vec::Vec<models::subscription_item_update_params::SubscriptionItemUpdateParams>` in the current scope
error[E0599]: no method named `to_string` found for reference `&models::order_timestamp_specs::OrderTimestampSpecs` in the current scope
error[E0599]: no method named `to_string` found for reference `&models::all_prices_recurring_params::AllPricesRecurringParams` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::discount_params::DiscountParams>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::line_item_params::LineItemParams>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::credit_note_line_item_params::CreditNoteLineItemParams>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::data_params::DataParams>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<i32>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::add_invoice_item_entry::AddInvoiceItemEntry>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::subscription_item_create_params::SubscriptionItemCreateParams>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::subscription_item_update_params::SubscriptionItemUpdateParams>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::order_item_specs::OrderItemSpecs>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::tier::Tier>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::phase_configuration_params::PhaseConfigurationParams>` in the current scope
error[E0599]: no method named `join` found for struct `std::vec::Vec<models::phase_configuration_params_1::PhaseConfigurationParams1>` in the current scope
error[E0282]: type annotations needed

Versions

wing328 commented 4 years ago

Please try the latest master or 5.0.0-beta2 to see if you still experience the same issue.

broccolihighkicks commented 4 years ago

Same errors with v5. Should this be fixed in that version?

I don't understand how the generator can output code that does not compile. Isn't the promise of machine readable specifications that there will be no errors in converting a spec to client code (that a human may make)?

Where should I be looking if I wanted to fix this? The generator framework or the HTML templates?

robert-chiniquy commented 3 years ago

FWIW I've hit nearly identical errors with the OpenAPI spec I've tried with 5.0.0 and latest master both, for example:

error: cannot find type `OneOfnumberstringstring` in module `crate::models`
broccolihighkicks commented 3 years ago

I am thinking of merging my fix, but it needs work.

If anyone is interested in generating Rust clients let me know.

robert-chiniquy commented 3 years ago

If you tell me how to build it to try it out I'm happy to try it against some specs.

dmitrymur commented 3 years ago

@broccolihighkicks I am also interested in the compilable Rust client library for stripe api.

Gained some experience on working with mustache templates so far. Will probably dive into Java code next. The unnamed schemas for request bodies/parameters/responses is pain in the *** Especially because how openapi-generator approaches it. Having some documentation on how the struct names are generated and how the generated names relate to concrete operation would be awesome. For now I will have to parse the generated code with rust_ast and so on, to get the type names of api function's parameters and/or return values.